|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
WMI/VB Script to rename multiple computers in a domain
Hi,
I need help to device a script that can rename multiple computers in my domain. "Satya" <Sa***@discussions.microsoft.com> wrote in message We need to know how you plan to rename these objects. Is the new name a news:555BC16B-50DD-46D3-9ACF-664618713209@microsoft.com... > Hi, > I need help to device a script that can rename multiple computers in my > domain. function of the old? Do you want the NetBIOS name of the computer to match the Common Name? In a VBScript program use the MoveHere method of the parent object (the OU/container the computer object resides in) to rename the computer account. See this link: http://www.microsoft.com/technet/scriptcenter/guide/sas_srv_fovn.mspx If all the computers are in an OU, ou can bind to the OU, filter on objects of class "computer", enumerate them in a For Each loop, and rename. Otherwise you can use the FileSystemObject to read computer names from a text file. In either case how will you know the new name? One idea could be to have a spreadsheet with the old and new names. If possible the old names should be Distinguished Names. The new names can be the new Common Names. Most likely you want the Common Name and NetBIOS names of the computer objects to match. You must use the MoveHere method to modify the Common Name (the value of the "cn" attribute). To modify the NetBIOS name, assign the new value to the sAMAccountName attribute of the computer object. Hi Richard,
First of all, I would like to thank you for responding to my query. Now coming to the plan that I have, the objective is to rename multiple systems through the script. When I rename the computers, it should update the system name in the client-end as well as update the same in the active directory. I devised a script for that matter, however the performance is very in-consistent. Most of the time, it is not able to fetch system names for most of the systems, so it fails. Secondly, the script fails while trying to rename more than 2 or 3 systems. Let me know in case I need to share the code. Regards Satya Show quote "Richard Mueller [MVP]" wrote: > > "Satya" <Sa***@discussions.microsoft.com> wrote in message > news:555BC16B-50DD-46D3-9ACF-664618713209@microsoft.com... > > Hi, > > I need help to device a script that can rename multiple computers in my > > domain. > > We need to know how you plan to rename these objects. Is the new name a > function of the old? Do you want the NetBIOS name of the computer to match > the Common Name? > > In a VBScript program use the MoveHere method of the parent object (the > OU/container the computer object resides in) to rename the computer account. > See this link: > > http://www.microsoft.com/technet/scriptcenter/guide/sas_srv_fovn.mspx > > If all the computers are in an OU, ou can bind to the OU, filter on objects > of class "computer", enumerate them in a For Each loop, and rename. > Otherwise you can use the FileSystemObject to read computer names from a > text file. In either case how will you know the new name? > > One idea could be to have a spreadsheet with the old and new names. If > possible the old names should be Distinguished Names. The new names can be > the new Common Names. Most likely you want the Common Name and NetBIOS names > of the computer objects to match. You must use the MoveHere method to modify > the Common Name (the value of the "cn" attribute). To modify the NetBIOS > name, assign the new value to the sAMAccountName attribute of the computer > object. > > -- > Richard Mueller > Microsoft MVP Scripting and ADSI > Hilltop Lab - http://www.rlmueller.net > -- > > > The only method I know to rename a computer (not just the AD object)
requires that you run the script on the local computer. See this link: http://www.microsoft.com/technet/scriptcenter/scripts/ad/computer/cptrvb14.mspx This also only works on XP and W2k3. Unless you have another method, the only solution I can think of is to deploy a similar script remotely. That is, connect to each computer, copy the executable to the local drive, run it, then delete it and move to the next computer. I have an example VBScript program that does that linked here: http://www.rlmueller.net/Deploy.htm This program deploys to all computers in a group. It logs everything to a log file. Of course the executable must run silently with no user input. You will need to either pass the new computer name to the script as a parameter, or somehow have the script retrieve (or calculate) the new name. Show quote "Satya" <Sa***@discussions.microsoft.com> wrote in message news:30933242-26BF-4BEC-B6C9-4A9594AE582E@microsoft.com... > Hi Richard, > First of all, I would like to thank you for responding to my query. > > Now coming to the plan that I have, the objective is to rename multiple > systems through the script. When I rename the computers, it should update > the > system name in the client-end as well as update the same in the active > directory. > > I devised a script for that matter, however the performance is very > in-consistent. Most of the time, it is not able to fetch system names for > most of the systems, so it fails. Secondly, the script fails while trying > to > rename more than 2 or 3 systems. > > Let me know in case I need to share the code. > > Regards > Satya > > "Richard Mueller [MVP]" wrote: > >> >> "Satya" <Sa***@discussions.microsoft.com> wrote in message >> news:555BC16B-50DD-46D3-9ACF-664618713209@microsoft.com... >> > Hi, >> > I need help to device a script that can rename multiple computers in my >> > domain. >> >> We need to know how you plan to rename these objects. Is the new name a >> function of the old? Do you want the NetBIOS name of the computer to >> match >> the Common Name? >> >> In a VBScript program use the MoveHere method of the parent object (the >> OU/container the computer object resides in) to rename the computer >> account. >> See this link: >> >> http://www.microsoft.com/technet/scriptcenter/guide/sas_srv_fovn.mspx >> >> If all the computers are in an OU, ou can bind to the OU, filter on >> objects >> of class "computer", enumerate them in a For Each loop, and rename. >> Otherwise you can use the FileSystemObject to read computer names from a >> text file. In either case how will you know the new name? >> >> One idea could be to have a spreadsheet with the old and new names. If >> possible the old names should be Distinguished Names. The new names can >> be >> the new Common Names. Most likely you want the Common Name and NetBIOS >> names >> of the computer objects to match. You must use the MoveHere method to >> modify >> the Common Name (the value of the "cn" attribute). To modify the NetBIOS >> name, assign the new value to the sAMAccountName attribute of the >> computer >> object. >> >> -- >> Richard Mueller >> Microsoft MVP Scripting and ADSI >> Hilltop Lab - http://www.rlmueller.net >> -- >> >> >> For this type of task I always turn to NETDOM. You should be able to use it
remotely and call it from a VBScript. It will take care of updating the computer object in AD. NETDOM RENAMECOMPUTER machine /NewName:new-name /UserD:user [/PasswordD:[password | *]] [/UserO:user [/PasswordO:[password | *]]] [/Force] [/REBoot[:Time in seconds]] NETDOM RENAMECOMPUTER renames a computer that is joined to a domain. The computer object in the domain is also renamed. Certain services, such as the Certificate Authority, rely on a fixed machine name. If any services of this type are running on the target computer, then a computer name change would have an adverse impact. This command should not be used to rename a domain controller. -- Jeffery Hicks Microsoft PowerShell MVP http://www.scriptinganswers.com http://blog.sapien.com Now Available: WSH and VBScript Core: TFM Coming Soon: Windows PowerShell: TFM 2nd Ed. Show quote "Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in message news:evniVbIHIHA.1208@TK2MSFTNGP03.phx.gbl... > > "Satya" <Sa***@discussions.microsoft.com> wrote in message > news:555BC16B-50DD-46D3-9ACF-664618713209@microsoft.com... >> Hi, >> I need help to device a script that can rename multiple computers in my >> domain. > > We need to know how you plan to rename these objects. Is the new name a > function of the old? Do you want the NetBIOS name of the computer to match > the Common Name? > > In a VBScript program use the MoveHere method of the parent object (the > OU/container the computer object resides in) to rename the computer > account. See this link: > > http://www.microsoft.com/technet/scriptcenter/guide/sas_srv_fovn.mspx > > If all the computers are in an OU, ou can bind to the OU, filter on > objects of class "computer", enumerate them in a For Each loop, and > rename. Otherwise you can use the FileSystemObject to read computer names > from a text file. In either case how will you know the new name? > > One idea could be to have a spreadsheet with the old and new names. If > possible the old names should be Distinguished Names. The new names can be > the new Common Names. Most likely you want the Common Name and NetBIOS > names of the computer objects to match. You must use the MoveHere method > to modify the Common Name (the value of the "cn" attribute). To modify the > NetBIOS name, assign the new value to the sAMAccountName attribute of the > computer object. > > -- > Richard Mueller > Microsoft MVP Scripting and ADSI > Hilltop Lab - http://www.rlmueller.net > -- > > |
|||||||||||||||||||||||