 <p>You could try something like this in PowerShell to check that the named computer is in the OU or not:</p> <p><strong>Script:</strong></p> <pre><code>import-module activedirectory $OU = @() $CheckOU = "LaptopOU" $computerName = "Laptop12345" $user = get-adcomputer $computerName -Properties * $user.DistinguishedName -split "," | %{If($_ -match "OU="){$OU += $_ -replace "OU=",""}} If($OU -match $CheckOU){ "Computer:$computerName is in the OU:$CheckOU" # Do something... } Else{ "Computer:$computerName is not in the OU:$CheckOU" # Do something else.. } </code></pre> <p>This will take a <code>$computerName</code> and get all the OU's that it's in from Active Directory and stores them in an <code>$OU</code> array. </p> <p>Then you can use that array to simply check if the computer is in the given OU (<code>$CheckOU</code>) or not by using the <code>-match</code> operator. </p> <p><strong>Note:</strong> You need to make sure that you import the <code>activedirectory</code> module. If you do not have this to import follow this link for how to get it: <a href="http://blogs.msdn.com/b/rkramesh/archive/2012/01/17/how-to-add-active-directory-module-in-powershell-in-windows-7.aspx" rel="nofollow">activedirectory module</a> </p> <p>For more Cmdlet's and syntax on the Powershell Active Directory module follow this <a href="http://technet.microsoft.com/en-us/library/ee617195.aspx" rel="nofollow">Link</a></p>