PowerShell輸入以下命令
Get-ADuser -filter * -Properties * | Select-Object Name,SID, Created,PasswordLastSet,@{n="lastLogonDate";e={[datetime]::FromFileTime($_.lastLogonTimestamp)}} | Export-CSV Accountlist.csv -NoTypeInformation -Encoding UTF8
輸出檔案儲存位置
其中OU=Test user,DC=sayms,DC=COM需要根據你實際的OU情況替換,效果如下:
Get-ADuser -searchbase ' OU=Test user,DC=sayms,DC=COM ' -filter * -Properties * | Select-Object Name,SID, Created,PasswordLastSet,@{n="lastLogonDate";e={[datetime]::FromFileTime($_.lastLogonTimestamp)}} | Export-CSV Accountlist.csv -NoTypeInformation -Encoding UTF8