6

Why does Get-Computers -OperatingSystem "Windows VistaT Business" not return anything? It works perfectly for all the other OS types.

Function Get-Computers
{
    Param($OperatingSystem)

    Get-AdComputer -Filter 'OperatingSystem -eq ${OperatingSystem}' -SearchBase "OU=Departement,DC=contoso,DC=com"
}

#Get-Computers -OperatingSystem "Windows Server 2012 R2 Standard"
#Get-Computers -OperatingSystem "Windows Server 2008 R2 Standard"
#Get-Computers -OperatingSystem "Windows 7 Professional"
Get-Computers -OperatingSystem "Windows VistaT Business"

I definitly do have Vista clients and the string to look for is Windows VistaT Business.

PS C:\> (get-adcomputer ClientA -Properties *).OperatingSystem
Windows 7 Professional
PS C:\> (get-adcomputer ClientB -Properties *).OperatingSystem
Windows VistaT Business
  • Why the down vote? My question is specific and clear – Matze Nov 21 '14 at 16:00
  • 1
    Does the computer live in your searchbase? Could the computer object be in another OU than what you're searching? – Colyn1337 Nov 21 '14 at 16:56
9

That T in "VistaT" is no T at all - it represents a trademark symbol: ™ (U+2122 or #8482 in Unicode)

Try this:

Get-Computers -OperatingSystem $("Windows Vista" + [char]8482 + " Business")

Why Microsoft chose to abuse the ability to store unicode symbols in string value attributes in this way is beyond me.


Here is how I found out:

(When you cast a .NET char to an integer, you'll get the byte value for ASCII chars, or a 2-byte codepoint for unicode characters)

$osString = (Get-ADComputer [VistaComputerName] -Properties operatingSystem).operatingSystem

foreach($c in $osString.ToCharArray())
{
    Write-Host $("$c: " + "$([int]$c)")
}

At this point, my output consisted of all ASCII chars (all integers a single byte), except for the T:

W: 87
i: 105
n: 110
d: 100
o: 111
w: 119
s: 115
 : 32
V: 86
i: 105
s: 115
t: 116
a: 97
T: 8482
 : 32
B: 66
u: 117
s: 115
i: 105
n: 110
e: 101
s: 115
s: 115
  • 2
    Microsoft's relationship with Unicode is such a sordid tale. – Ryan Ries Nov 21 '14 at 17:56
  • I would never have figued that out by myself. Thanks! – Matze Nov 24 '14 at 15:26
  • 1
    Updated answer with how I actually found out – Mathias R. Jessen Nov 24 '14 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.