Mat*_*ert 6 powershell active-directory user-management
为什么不Get-Computers -OperatingSystem "Windows VistaT Business"
返回任何东西?它适用于所有其他操作系统类型。
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"
Run Code Online (Sandbox Code Playgroud)
我肯定有 Vista 客户端,要查找的字符串是Windows VistaT Business
.
PS C:\> (get-adcomputer ClientA -Properties *).OperatingSystem
Windows 7 Professional
PS C:\> (get-adcomputer ClientB -Properties *).OperatingSystem
Windows VistaT Business
Run Code Online (Sandbox Code Playgroud)
这T
在“VistaT”是根本没有T -它代表了一个商标符号:™(U + 2122或#8482以Unicode)
尝试这个:
Get-Computers -OperatingSystem $("Windows Vista" + [char]8482 + " Business")
Run Code Online (Sandbox Code Playgroud)
为什么 Microsoft 选择以这种方式滥用在字符串值属性中存储 unicode 符号的能力,这超出了我的理解。
这是我如何发现的:
(当您将 .NETchar
转换为整数时,您将获得 ASCII 字符的字节值,或 unicode 字符的 2 字节代码点)
$osString = (Get-ADComputer [VistaComputerName] -Properties operatingSystem).operatingSystem
foreach($c in $osString.ToCharArray())
{
Write-Host $("$c: " + "$([int]$c)")
}
Run Code Online (Sandbox Code Playgroud)
此时,我的输出包含所有 ASCII 字符(所有整数都是一个字节),除了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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1090 次 |
最近记录: |