0
下面的腳本爲我提供了一個帳戶的正確輸入,當添加多個帳戶時它不起作用。我如何才能使它適用於csv文件中列出的所有用戶帳戶?來自csv文件的get-aduser lastlogon passwordexpire
$csv = import-csv "c:\users.csv"
foreach($user in $csv){
$Displayname = $user.Displayname
Get-aduser -filter {displayname -eq $displayname}`
-Properties displayName,employeeID,mail, "msDS-UserPasswordExpiryTimeComputed","lastLogonTimestamp" |`
select "Displayname","Enabled",@{Name="PasswordExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}},@{N='LastLogonTime'; E={[DateTime]::FromFileTime($_.lastLogonTimestamp)}},SamAccountName,employeeID,mail |`
Export-Csv "c:\temp\users1.csv"
}
出口-CSV「C時被覆蓋:\ temp \ users1.csv「 - 擴展? – Itchydon
-append開關確實有效 –
太好了。我已經將其添加爲答案 – Itchydon