|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I am looking to automate the process of moving computers that get into our
computers container. I've found scripts that talk about moving computers, but is it possible to scan the first 4-5 characters of the computer account name an move it based on that. Example: Computer name starts with... PS-E... would get moved to a specific OU PS-S... would get moved to a different OU PS-T... would get moved to a different OU Here are the links to the information i've found so far... http://www.microsoft.com/technet/scr...1.mspx?pf=true http://www.microsoft.com/technet/scr...t.mspx?pf=true http://www.microsoft.com/communities...=en-us&m=1&p=1 http://www.microsoft.com/communities...=en-us&m=1&p=1 Much Appreciated, Jordi |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Jordi wrote:
>I am looking to automate the process of moving computers that get into our > computers container. I've found scripts that talk about moving computers, > but is it possible to scan the first 4-5 characters of the computer > account > name an move it based on that. > > Example: > > Computer name starts with... > > PS-E... would get moved to a specific OU > PS-S... would get moved to a different OU > PS-T... would get moved to a different OU > >...snip In brief, the code to move the computers could be similar to below: =============== Option Explicit Dim objPSE, objPSS, objPST Dim objContainer, objComputer, strOU ' Bind to the target OU's (do this once). Set objPSE = GetObject("LDAP://ou=PSE,ou=West,dc=MyDomain,dc=com") Set objPSS = GetObject("LDAP://ou=PSS,ou=West,dc=MyDomain,dc=com") Set objPST = GetObject("LDAP://ou=PST,ou=West,dc=MyDomain,dc=com") ' Bind to container object. Set objContainer = GetObject("LDAP://cn=Computers,dc=MyDomain,dc=com") ' Filter on computer objects. objContainer.Filter = Array("computer") ' Enumerate all computers in container. For Each objComputer In objContainer ' Check first 4 characters (upper case) of NetBIOS Name. strOU = Left(UCase(objComputer.sAMAccountName), 4) Select Case strOU Case "PS-E" objPSE.MoveHere objComputer.AdsPath, vbNullString Case "PS-S" objPSS.MoveHere objComputer.AdsPath, vbNullString Case "PS-T" objPST.MoveHere objComputer.AdsPath, vbNullString End Select Next -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Brilliant!! This is exactly what i was looking. Thanks Richard!!
"Richard Mueller [MVP]" wrote: > Jordi wrote: > > >I am looking to automate the process of moving computers that get into our > > computers container. I've found scripts that talk about moving computers, > > but is it possible to scan the first 4-5 characters of the computer > > account > > name an move it based on that. > > > > Example: > > > > Computer name starts with... > > > > PS-E... would get moved to a specific OU > > PS-S... would get moved to a different OU > > PS-T... would get moved to a different OU > > > >...snip > > In brief, the code to move the computers could be similar to below: > =============== > Option Explicit > Dim objPSE, objPSS, objPST > Dim objContainer, objComputer, strOU > > ' Bind to the target OU's (do this once). > Set objPSE = GetObject("LDAP://ou=PSE,ou=West,dc=MyDomain,dc=com") > Set objPSS = GetObject("LDAP://ou=PSS,ou=West,dc=MyDomain,dc=com") > Set objPST = GetObject("LDAP://ou=PST,ou=West,dc=MyDomain,dc=com") > > ' Bind to container object. > Set objContainer = GetObject("LDAP://cn=Computers,dc=MyDomain,dc=com") > ' Filter on computer objects. > objContainer.Filter = Array("computer") > > ' Enumerate all computers in container. > For Each objComputer In objContainer > ' Check first 4 characters (upper case) of NetBIOS Name. > strOU = Left(UCase(objComputer.sAMAccountName), 4) > Select Case strOU > Case "PS-E" > objPSE.MoveHere objComputer.AdsPath, vbNullString > Case "PS-S" > objPSS.MoveHere objComputer.AdsPath, vbNullString > Case "PS-T" > objPST.MoveHere objComputer.AdsPath, vbNullString > End Select > Next > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > > > |
|
![]() |
| Outils de la discussion | |
|
|