Powershell to get AD user disabled in the past 6 months?

僤鯓⒐⒋嵵緔 提交于 2020-06-17 09:59:26

问题


How to get the AD user that was disabled in the past 6 months and also the time stamp when it was disabled in dd/MM/yyyy format as.CSV file?

Like using this Powershell https://docs.microsoft.com/en-us/powershell/module/addsadministration/get-aduser?view=win10-ps ?

$paramhash=@{
UsersOnly = $True
AccountDisabled = $True
SearchBase = "OU=Employees,DC=globomantics,dc=local"
}

Search-ADAccount @paramHash |
Get-ADuser -Properties Description,Department,Title,LastLogonDate,WhenChanged | 
sort LastLogonDate | 
Select Name,Department,Title,Description,WhenChanged,LastLogonDate,DistinguishedName | 
out-gridview -title "Disabled Employees"

回答1:


Instead of using Out-GridView to display the results, you need to save them to a file. You can do that easily in the CSV format by using Export-Csv like this.

Export-Csv '.\DisabledEmployees.csv' -NoTypeInformation

To be clear, just replace the Out-GridView line at the end of the pipeline with this line.



来源:https://stackoverflow.com/questions/61542122/powershell-to-get-ad-user-disabled-in-the-past-6-months

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!