Reputation: 321
I'm trying to load powershell result into a CSV or text file
First I need to get all disabled account using this:
Search-ADAccount -AccountDisabled -UsersOnly |FT Name
And it will return bunch of names that has been disabled. What should I do to load it into a CSV or TXT file?
Here is what I tried:
Search-ADAccount -AccountDisabled -UsersOnly |FT Name | Export-CSV -Path C:\Users\hou\Downloads\Test.csv
But the result is a bunch of things like '27c87ef9bbda4f709f6b4002fa4af63c', not the name that I want to.
What should I do to do this?
Upvotes: 0
Views: 2269
Reputation: 5046
Maybe:
Search-ADAccount -AccountDisabled -UsersOnly |
Select Name |
Export-CSV -Path C:\Users\hou\Downloads\Test.csv -NoTypeInformation
Then you'll have a CSV file with just the Names (including a header), that you can use as input to your DB's CSV import.
Format-Table transforms the objects into a stream of Formatting records which are intended for output but not for further processing. If you want to learn more about this see:
How PowerShell Formatting and Outputting REALLY works
Upvotes: 2