问题
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