Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Domain: mydomain.com
"OU1\OU2\Computers\Opsmanager" is the OU and I want to check if certain computer is in this OU. IF it is then I want to execute certain code and if not then other. Thanks
There are probably a bunch of ways to do this but here is one the comes to mind.
; Construct the full domain ADSI path. ServerDn = dsGetProperty("LDAP://rootDSE", "serverName") ServerName = ItemExtract(1, ServerDn, ",") ServerName = ItemExtract(2, ServerName, "=") ServerDn = dsGetProperty("LDAP://rootDSE", "defaultNamingContext") ServerPath = "LDAP://%ServerName%/%ServerDN%" ; Find the conputers path ComputerName = "TestComputer" ComputerPath = dsFindPath(ServerPath, "(&(objectCategory=computer)(cn=%ComputerName%))") ; Search the path for the OU OuName = "TestOuTwo" If StrIndexNC( ComputerPath, "OU=%OuName%",1, @FWDSCAN) Message("Found", "%ComputerName% is in %OuName%") Else Message("Not Found", "%ComputerName% is NOT in %OuName%") EndIfBeyond, there be dragons
Article ID: W16306
File Created: 2005:02:18:12:19:44
Last Updated: 2005:02:18:12:19:44