Re: rename a local group in windows 2003




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





.



Relevant Pages

  • Re: rename a local group in windows 2003
    ... strComputer = objShell.ExpandEnvironmentStrings ... I tried to rename several local groups using the MoveHere method ... Didn't matter if I ran the script on the ... WinNT provider only rename domain groups, ...
    (microsoft.public.windows.server.scripting)
  • Re: rename a local group in windows 2003
    ... I tried to rename several local groups using the MoveHere method ... Didn't matter if I ran the script on the ... WinNT provider only rename domain groups, ... All AD and local objects are renamed using the MoveHere method of the ...
    (microsoft.public.windows.server.scripting)
  • Re: rename a local group in windows 2003
    ... strComputer = objNetwork.ComputernName ... variable in a script, but that is more work than is necessary. ... I tried to rename several local groups using the MoveHere ... WinNT provider only rename domain groups, ...
    (microsoft.public.windows.server.scripting)
  • Re: Script to Rename Computer Name in Domain
    ... i looking a script to rename computer name in domain server 2003 ... To rename a computer you bind to the parent OU/Container of the computer ... you would need to also prompt for the current name. ... ' Bind to the parent OU/container of computer object. ...
    (microsoft.public.windows.server.scripting)
  • Re: Rename File Using Strring Found in File?
    ... OK, thanks, but the script does not seem to rename the files. ... # sleep 1; ... to the string in this particular file that I want to match. ...
    (comp.lang.perl.misc)