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

Piping output from -whatif to a file

$
0
0

Hello,

I am sure this is a beginner question here but I am unable to find anything online about it.
I am trying to disable user accounts that have not logged into the domain for over 10 days. I am able to pull a list with the following:
Search-ADAccount -AccountInactive -TimeSpan ([timespan]10d) -UsersOnly | Set-ADUser -Enabled $false -whatif | Export-Csv -Path C:\inactive_users.csv

I see the list, but would like to go through it manually to make sure accounts that are needed do not get deleted. The problem is that when I pipe it to export-csv, it creates a blank file with nothing in it even though I do see the list on the screen

Is there something I am missing? Also, how can I tell it to look in certain OU’s and not the whole domain?

Any help would be greatly appreciated.

-CrankyGeek


Viewing all articles
Browse latest Browse all 13067

Trending Articles