新的PowerShell,我不明白爲什麼輸出文件中的SamAccountName列是空的。而IsDisabled列具有帳戶狀態結果。Powershell輸出文件缺少SamAccountName結果
Import-Csv $filename | Foreach-Object{
$user = ([ADSISEARCHER]"(samaccountname=$($_.SamAccountName))").FindOne()
if($user)
{
New-Object -TypeName PSObject -Property @{
SamAccountName = $user.SamAccountName
IsDisabled = $user.GetDirectoryEntry().InvokeGet('AccountDisabled')
}
}
else
{
Write-Warning "Can't find user '$($_.SamAccountName)'"
}
} | Export-Csv $filename
SamAccountName列仍爲空。 – user2132386 2013-03-04 16:09:34
抱歉,我會編輯它。我錯了。 – 2013-03-04 16:15:15
使用SamAccountName = $ user.Properties.samaccountname對其進行了更新,現在SamAccountName列的SystemDirectoryServices.ResultPropertyValueCollection作爲每個用戶的結果。我也試過$ user.Properties.SamAccountName,結果又是空白的。 – user2132386 2013-03-04 16:22:25