I currently have a script that will look at the machines OU and if it doesn't equal what I am looking for it will move the machine to that OU. I need to modify this script and I'm not sure how. I need the script to look at the machine name and if the machine name begins with "XD" move it to a designated OU. All other machines will go into a different OU. Here is what I am working with.
Set wshNetwork = CreateObject("WScript.Network") Set oFso = CreateObject("Scripting.FileSystemObject") Set objSysInfo = CreateObject( "ADSystemInfo" ) Set ArgObj = WScript.Arguments 'Use first argument as target OU strMachineObjectOU = "OU=Workstation TESTING,OU=Workstations,DC=NA,DC=ER,DC=COM" strComputerDN = objSysInfo.ComputerName nComma = InStr(strComputerDN,",") strCurrentOU = Mid(strComputerDN,nComma+1) wscript.echo strCurrentOU strComputerName = Left(strComputerDN,nComma - 1) 'If current ou is different than target OU. Move object If UCase(strCurrentOU) <> UCase(strMachineObjectOU) Then Set objNewOU = GetObject("LDAP://" & strMachineObjectOU) Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN, strComputerName) End If