So I'm importing some data from CSV and trying to do some cool stuff. But I'm noticing the back tick (`) is not properly escaping special characters.
I end up with the trailing "]" at the beginning of the line (instead of the first character), except on the last line:
I have tracked the problem down to the $display= line. The data in the other variables is fine. It doesn't matter whether I use [], (), <>, or {}, I get the same results. It's not escaping those characters. If I remove those characters, things display correctly. I just can't seem to get around this.
Ideas?
Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.
Code:
ForEach ($user in $users){
$username = $user.FirstName+"."+$user.LastName
$upn = $username+"@mydomain.com"
$state = $user.St
$party = $user.Party
$firstname = $user.FirstName
$lastname = $user.LastName
$display = "Gov. $FirstName $LastName `[$Party-$State`]"
write-host $username $upn $display
}
I end up with the trailing "]" at the beginning of the line (instead of the first character), except on the last line:
I have tracked the problem down to the $display= line. The data in the other variables is fine. It doesn't matter whether I use [], (), <>, or {}, I get the same results. It's not escaping those characters. If I remove those characters, things display correctly. I just can't seem to get around this.
Ideas?
Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.