Reputation: 43
I am simply trying to detect Domänen-Benutzer in my powershell script so I can ignore it.
I figured I can simply run a not equals if statement so I can ignore it. However this not working. I can detect everything else with this statement but I am pretty sure it is the ä that is screwing me over. I have had issues previosuly with powershell and umlauts. I can't figure out how to get the -eq or -ne statement to accept encoding though.
Simple Code:
$groups = Get-Content "EntferntGruppen.txt" -Encoding UTF8
$string = "Domänen-Benutzer"
foreach ($group in $groups){
if ($group -eq $string) {
$group
}else{
"nah"
}
}
I would like to add I have tried -Encoding Unicode, UTF7, UTF32, Default
I have also originally didn't bother with the $string variable and simply had if($group -eq "Domänen-Benutzer")
which also failed.
If someone could educate me on how to deal with umlauts that would be great!
At the request of @Olaf here are some inputs from the EntferntGruppen.txt, these are generated on the fly from an AD user.
Domänen-Benutzer
gl_SekretariatDUS
gl_ZeusUser
gl_LexwareUserSXF
gl_WEST_InternetUser
JederDUS
Upvotes: 0
Views: 76
Reputation: 15518
You can use the unicode 0x00E4 code here:
$string = "Dom$([char]0x00E4)nen-Benutzer"
Upvotes: 1