Created
August 30, 2017 16:49
-
-
Save doublenns/9b1b048a753f2a20fe54858f2ba5b9f8 to your computer and use it in GitHub Desktop.
Retrieve Active Directory Organizational Unit for machine and only display if matches w/ specified parameter
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
param([string]$env="DEV") | |
$computers = Get-Content Documents\servers.txt | |
Foreach ($server in $computers){ | |
$ou_result = ([adsisearcher]"(&(name=$server)(objectClass=computer))").findall().path | |
echo $ou_result | Select-String -Pattern $env -NotMatch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment