Re: rename a local group in windows 2003
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 2 Apr 2008 17:46:52 -0500
My mistake. I tried to rename several local groups using the MoveHere method
and got an error each time. Didn't matter if I ran the script on the
computer or remotely. I see that the examples in my reference book using the
WinNT provider only rename domain groups, with no explanation. Then I found
this link:
http://msdn2.microsoft.com/en-us/library/aa705991.aspx
which states:
Note The WinNT provider supports IADsContainer::MoveHere, but only for
renaming users & groups within a domain.
Turns out you must use WMI to rename local objects, like local users and
local groups. See this link:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/may06/hey0517.mspx
However, the computer OS must be XP or greater (like Windows Server 2003).
Otherwise the Rename method is not supported. If the NetBIOS name of the
server is "PLAPI0066" and the name of the local group is "test" and you want
to rename the local group to "test1", then this should work:
==========
strComputer = "PLAPI0066"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAccounts = objWMIService.ExecQuery _
("SELECT * FROM Win32_Account WHERE LocalAccount = True AND Name =
'test'")
For Each objAccount In colAccounts
objAccount.Rename "test1"
Next
============
I used the Win32_Account class instead of the Win32_UserAccount class
refered to in the link, in order to include both user and group accounts. I
tested the above on an XP computer and it worked.
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
"lolo1790" <lolo1790@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CB59A0E1-CFD7-451A-996C-C3AAAFDA7CE5@xxxxxxxxxxxxxxxx
thank you
but it don't work
see the modify script :
'Bind to the local computer object.
Set objComputer = GetObject("WinNT://MyServer,computer")
' Rename local group "test" to "test1".
objComputer.MoveHere "WinNT://MyServer/test,group", "test1"
i want to modify local group "test" in "test1" in server PLAPI0066, what
is
the script ?
thanks
"Richard Mueller [MVP]" wrote:
lolo1790 wrote:
i want to rename a local group in windows 2003.
for exemple i want to rename local group test in test1
i search a script, help me please
All AD and local objects are renamed using the MoveHere method of the
parent
object. For local objects, the parent is the computer and you must use
the
WinNT provider. For example:
===========
' Bind to the local computer object.
Set objComputer = GetObject("WinNT://MyServer,computer")
' Rename local group "GroupOld" to "GroupNew".
objComputer.MoveHere "WinNT://MyServer/GroupOld,group", "GroupNew"
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
.
- Follow-Ups:
- Re: rename a local group in windows 2003
- From: lolo1790
- Re: rename a local group in windows 2003
- References:
- rename a local group in windows 2003
- From: lolo1790
- Re: rename a local group in windows 2003
- From: Richard Mueller [MVP]
- Re: rename a local group in windows 2003
- From: lolo1790
- rename a local group in windows 2003
- Prev by Date: Re: can JScript go through properties of an OFFICE object?
- Next by Date: Re: nslookup
- Previous by thread: Re: rename a local group in windows 2003
- Next by thread: Re: rename a local group in windows 2003
- Index(es):
Relevant Pages
|