Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Piping output from -whatif to a file

$
0
0

Hello Matthew,

You don’t need to use -WhatIf to get the expected result for your review. The Search-ADAccount cmdlet returns ADUser objects with the Enabled property which you can use to filter for only enabled inactive users, select the properties required in your CSV and pipe to Export-Csv.

Example:
Search-ADAccount -AccountInactive -TimeSpan ([timespan]10d) -UsersOnly |
Where-Object -FilterScript { $_.Enabled -eq $true } | Select-Object -Property SamAccountName, LastLogonDate, DistinguishedName |
Export-Csv -Path C:\enabled_inactive_users.csv -NoTypeInformation

I hope above helps.

Best,
Daniel


Viewing all articles
Browse latest Browse all 13067

Trending Articles