Created
June 9, 2015 08:48
-
-
Save alexinnes/942175f54a44bd8f4526 to your computer and use it in GitHub Desktop.
Get Computers in Active Directory in Certain OUs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Where do you want the file to be exported to | |
$Export = "C:\" | |
#What OU Do you want to target | |
$OU=@("OU=PS,DC=ps,DC=internal","OU=TCASP,DC=ps,DC=internal") | |
#loop through the array of OUs and find all the computers. Selects the: Name, Operatingsystem, lastlogondate, modified, Created and Canonicalname and exports to CSV | |
$OU | foreach { get-adcomputer -Filter * -SearchBase $_ -Properties * | |
| select -Property Name, Operatingsystem, lastlogondate, modified, Created, Canonicalname} | export-csv $Export |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment