depending on how you look at it, you are either in luck, or you are in
trouble :)
enjoy
Sincerely,
D�j� Ak�m�l�f�, MCSE MCSA MCP+I
Microsoft MVP - Directory Services
www.readymaids.com - we know IT
www.akomolafe.com
Do you now realize that Today is the Tomorrow you were worried about
Yesterday? -anon
________________________________
From: [EMAIL PROTECTED] on behalf of joe
Sent: Mon 6/21/2004 11:19 AM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] PC move
You could also have the script look at the dnsHostName, do a lookup (fairly
easy in perl, not so sure for vbscript) and then do the move. Keep in mind
people who move about from location to location. Also keep in mind what do
you do with machines that don't have a host name that can be looked up for
some reason or are in an IP you aren't expecting.
I can understand where someone would do this. Say you originally didn't have
a clean site structure for where machines went for admin organization and
you all of a sudden want to do so. Like say for instance you walk into a
location that gave all admins the ability to create machines in computers
and then someone realized that gave all admins rights on all machines and
now they want to break them up to delegated OUs with good controls... Etc
etc.
joe
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tony Murray
Sent: Monday, June 21, 2004 7:41 AM
To: [EMAIL PROTECTED]
Subject: Re: [ActiveDir] PC move
I don't know of any easy way to do this. As the IP address information is
not stored in AD, I guess you would need to do this with a script (probably
using WMI) to directly query each machine who's object is in the first OU
and then perform the move using ADSI based on the retrieved IP address
information. If the PCs get their IP allocated by DCHP then you'd have to
derive the IP information from the DHCP server(s).
I can't think of a good reason why you would want to do this in the first
place? Typically you create OUs for delegation of administration and/or
Group Policy application. If you're doing this for GPO purposes you could
consider defining separate sites based on the IP subnets and then applying
Site GPOs.
Tony
---------- Original Message ----------------------------------
Wrom: EGAUTFJMVRESKPNKMBIPBARHDMNNSKVFVWRKJVZCMHVIBGDADRZFSQHYUCD
Reply-To: [EMAIL PROTECTED]
Date: Mon, 21 Jun 2004 15:45:01 +0530
I want to move PC's from one OU to another OU based on IP Subnet.
Details :
I want to move all PC's whose IP is 10.238.10.* and 10.238.20.* from
"Office" OU to "Home" OU. I want to do this in bulk command.
Regards,
Dinesh Tashildar
________________________________________________________________
Sent via the WebMail system at mail.activedir.org
List info : http://www.activedir.org/mail_list.htm
List FAQ : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
List info : http://www.activedir.org/mail_list.htm
List FAQ : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
'Option Explicit
Const ADS_SCOPE_SUBTREE = 2
Set FSO=CreateObject("Scripting.FileSystemObject")
Set FSOWriteNO=FSO.OpenTextFile("D:\list_NoResponse_Computers.xls", 8, True)
Set FSOWriteDC=FSO.OpenTextFile("D:\list_DCs.xls", 8, True)
Set FSOWriteReport=FSO.OpenTextFile("D:\Moved_Computers.xls", 8, True)
FSOWriteNO.WriteLine ("Computer Name") & vbTab & ("Location")
Set objShell = CreateObject("Wscript.Shell")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, distinguishedName from 'LDAP://DC=myDomain,DC=com' " _
& "where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
objComputerName = objRecordSet.Fields("Name").Value
objComputerDN = objRecordSet.Fields("distinguishedName").Value
'Don't touch the Domain controller's OU
if instr (UCASE(objComputerDN), UCASE("Domain Controllers")) > 0 Then
FSOWriteDC.WriteLine UCASE(objComputerName) & vbTab & " IS IN " &
vbTab & UCASE(objComputerDN)
Else
'Don't touch the ComputersOU's OU. Objects here are already moved
'if instr (UCASE(objComputerDN), UCASE("ComputersOU")) > 0 Then
'Else
'Uncomment this to specify a computer to move by name
'if instr (UCASE(objComputerDN), UCASE("computer1")) > 0 Then
Set objScriptExec = objShell.Exec("ping -n 1 -w 1 " &
UCASE(objComputerName))
strPing = ObjScriptExec.StdOut.ReadAll
'We are just trying to get the IP, not check whether the computer is
alive or not
if instr (UCASE(strPing), UCASE("Pinging")) > 0 Then
if instr (strPing, "10.210") > 0 Then
strNewOU = "OU210"
Else
if instr (strPing, "10.220") > 0 Then
strNewOU = "OU220"
Else
if instr (strPing, "10.230") > 0 Then
strNewOU = "OU230"
Else
if instr (strPing, "255.130") > 0 Then
strNewOU = "OU255130"
Else
if instr (strPing, "255.100") > 0 Then
strNewOU = "OU255100"
Else
if instr (strPing, "255.110") > 0 Then
strNewOU = "TOK"
Else
if instr (strPing, "255.120") > 0 Then
strNewOU = "OU255120"
Else
if instr (strPing, "10.240") > 0 Then
strNewOU = "OU240"
End If
End If
End If
End If
End If
End If
End If
End If
objNewOU = "LDAP://OU=" & strNewOU &
",OU=ComputersOU,DC=myDomain,DC=com"
objComputerCN = "CN=" & objComputerName
objComputerLDAP = "LDAP://" & objComputerDN
On Error Resume Next
Set objMoveComputer = GetObject(objNewOU)
Wscript.Echo objComputerName
objMoveComputer.MoveHere objComputerLDAP, objComputerCN
Set objMoveComputer = Nothing
FSOWriteReport.WriteLine objComputerName & vbTab & strNewOU
Else
FSOWriteNo.WriteLine objComputerName & vbTab & objComputerDN
End If
'Uncomment this to specify a computer to move by name
'End If
'End If 'this ends the ComputersOU exception loop
End If 'this ends the Domain controllers exception loop
objRecordSet.MoveNext
Loop
FSOWriteDC.Close
set FSOWriteDC=nothing
FSOWriteNO.Close
set FSOWriteNO=nothing
set FSO=nothing