导出用户的名字,上次登录时间,上次密码重置时间,邮件并以CSV格式保存。
Get-ADUser - Filter * -Properties * -SearchBase " dc=superdoor,dc=co, dc=nz" |Select -Object Name, lastlogondate, passwordlastset, mail | Export-Csv -Path "c:\userinfo.csv"
导出OU下面的用户,加上对应的OU即可
Get-ADUser - Filter * -Properties * -SearchBase "ou=nation dc=superdoor,dc=co, dc=nz" |Select -Object Name, lastlogondate, passwordlastset, mail | Export-Csv -Path "c:\userinfo.csv"
$file = “C:\info.csv”
Get-ADUser -Filter * -Properties DisplayName,mail,LastLogonDate |
Select-Object -Property DisplayName,mail,LastLogonDate |
Export-Csv -NoTypeInformation -Path $file -Encoding UTF8
导出用户电话
Get-ADUser -Filter * -SearchBase "ou=contoso,dc=contoso,dc=com" -Properties * | where {$_.UserPrincipalName -ne $null} | Select-Object SamAccountName,telephoneNumber | Export-Csv -Encoding Utf8 -NoTypeInformation c:\aduserinfo.csv
修改后导入
Import-Csv -Path c:\tel.csv |ForEach-Object {Set-ADUser -Identity $_.SamAccountName -Replace @{telephoneNumber=$_.telephoneNumber} }