Re: Membership...
- From: "Fan Fan" <ffan102@xxxxxxxxxxx>
- Date: Fri, 22 Jul 2005 15:15:21 -0700
Hi, Torgeir,
Thanks again for the solution for my previous posting.
As I work along, I am facing another problem. That is, the local
Administrators group in some computers contrain members with deleted domain
account (or it maybe from another domain we scrapped) such as this:
S-1-5-21-745281606-593586046-1819828000-500. What is "mydomain" suposed to
be since the account is unknown or no longer exist? I have about 500 pc to
work with. Please help again.
Fan
"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@xxxxxxxxx> wrote in message
news:%23UOH9GvjFHA.576@xxxxxxxxxxxxxxxxxxxxxxx
> Fan Fan wrote:
>
>> Please help.
>> I would like to remove DOMAIN account from a LOCAL administrators group
>> REMOTELY using vb script. Can anybody either point me the way for more
>> reading material for the subject or present me with the vb script? The
>> following script can remove the member of the Administrators group if the
>> account is a LOCAL account to that computer. If the account is a DOMAIN
>> account, I got the error with message: 'A member could not be added or
>> removed from the local group because the member does not exist'.
>>
>> Dim oDomain,oGroup,sDomain,sGroup,sUser
>> sDomain = "TheRemotePC" 'local host; member of the Active Directory
>> domain
>> sGroup = "Administrators"
>> sUser = "JDow" 'a domain account; not an account to the local pc
>> Set oDomain = GetObject("WinNT://" & sDomain)
>> Set oGroup = oDomain.GetObject("Group", sGroup)
>> oGroup.Remove("WinNT://" & sDomain & "/" & sUser)
>>
> Hi,
>
> You need to include the domain the user is member of in the ADsPath
> you feed to the Remove method.
>
> This works for me:
>
> '--------------------8<----------------------
> Option Explicit
>
> Dim sComputer, sUserDomain, sGroup, sUser, oGroup
>
> sComputer = "TheRemotePC" ' local host; member of the Active Directory
> domain
> sUserDomain = "mydomain" ' the domain the user is member of
> sGroup = "Administrators"
> sUser = "JDow" ' a domain account; not an account to the local
> pc
>
> Set oGroup = GetObject("WinNT://" & sComputer & "/" & sGroup & ",group")
> oGroup.Remove("WinNT://" & sUserDomain & "/" & sUser)
>
> '--------------------8<----------------------
>
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
.
- References:
- Membership...
- From: Fan Fan
- Re: Membership...
- From: Torgeir Bakken \(MVP\)
- Membership...
- Prev by Date: Querying AD with the LIKE operator
- Next by Date: Change fax # in AD
- Previous by thread: Re: Membership...
- Next by thread: Shortcut to a shared folder
- Index(es):
Relevant Pages
|