How to export Active Directory objects like computers, users, AD groups and printers information can be exported to an Excel CSV file, here are the simple code helps to achieve the same.
System administrator as part of the daily tasks they work on active directory object when one wants to export all the AD objects to a CSV file with a PowerShell then here is the simple script does export all Organization units, computer objects, AD groups, Users and more.
One can also modify this simple code and get the required information, it generates the report in CSV file in minutes, here is the script.
Get-ADObject -Filter 'Name -like "*"' | Where-Object {$_.ObjectClass -eq "user" -or $_.ObjectClass -eq "computer" -or $_.ObjectClass -eq "group" -or $_.ObjectClass -eq "organizationalUnit"} | Sort-Object ObjectClass | Export-CSV C:\Temp\ExportAD.csv -notypeinformation
when you want to pull only the computer objects then the script looks as below.
Get-ADObject -Filter 'Name -like "*"' | Where-Object {$_.ObjectClass -eq "computer"} | Sort-Object ObjectClass | Export-CSV C:\Temp\ExportAD.csv -notypeinformation
If you need only user accounts in active directory.
Get-ADObject -Filter 'Name -like "*"' | Where-Object {$_.ObjectClass -eq "computer"} | Sort-Object ObjectClass | Export-CSV C:\Temp\ExportAD.csv -notypeinformation
Thank you for reading this article, if you have any questions please let us know.
Thank you for visiting my site, for any scripts in these articles you are testing please make sure you have tested this script in our lower environment before you run in production.
Leave a Reply Cancel reply