我正在尝试运行下面的脚本,但是当我运行时我得到了
Unexpected token '-PrimaryUserAddress' in expression or statement
我该如何解决这个问题?
$users = Get-ADUser "joerod" -Properties *|Select-Object SamAccountName, msRTCSIP-PrimaryUserAddress
ForEach ($user in $users) {
if($user.msRTCSIP-PrimaryUserAddress -ne 0){
Write-Host "Removing $($user.samaccountname) from OCS"
}
}
最佳答案
解析器正在命中 - 并将其解释为 Powershell 运算符。单引号属性,以便将其解释为文字字符串:
if($user.'msRTCSIP-PrimaryUserAddress' -ne 0)
关于Powershell 如果格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21938552/