PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.win.server.scripting > Move Computer Accounts from Computer Container
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Move Computer Accounts from Computer Container

Réponse
 
LinkBack Outils de la discussion
Vieux 27/09/2008, 03h11   #1
Jordi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Move Computer Accounts from Computer Container

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



  Réponse avec citation
Vieux 27/09/2008, 15h23   #2
Richard Mueller [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Move Computer Accounts from Computer Container

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
--


  Réponse avec citation
Vieux 29/09/2008, 21h04   #3
Jordi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Move Computer Accounts from Computer Container

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
> --
>
>
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h28.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12253 seconds with 11 queries