Im sure the DN name is correct and I changed the string as shown below
but still get an error:
PS C:\Documents and Settings\Administrator> $client
distinguishedName
-----------------
{CN=TEST-01,OU=XPClients,DC=testdomain,DC=co,DC=uk}
PS C:\Documents and Settings\Administrator> $group
distinguishedName
-----------------
{CN=Test Group,CN=Users,DC=testdomain,DC=co,DC=uk}
PS C:\Documents and Settings\Administrator>
$group.psbase.properties["member"].remove("CN=TEST-01,OU=XPClients,DC=testdomain,DC=co,DC=uk")
PS C:\Documents and Settings\Administrator>
$group.psbase.commitChanges()
Exception calling "CommitChanges" with "0" argument(s): "The server is
unwilling to process the request. (Exception fro
m HRESULT: 0x80072035)"
At line:1 char:28
+ $group.psbase.commitChanges( <<<< )
PS C:\Documents and Settings\Administrator>
On Jan 5, 10:38 am, /\/\o\/\/ [MVP] <o...@discussions.microsoft.com>
wrote:
> most likely the DN name is not correct, note that LDAP:// must NOT be incluyded
>
> gr /\/\o\/\/
>
> "char1iecha1k" wrote:
> > OK, that seems to get me further, but now I am getting this error when
> > i try this:
>
> > PS C:\> $group.psbase.commitchanges()
>
> > Exception calling "CommitChanges" with "0" argument(s): "The server is
> > unwilling to process the request. (Exception fro
> > m HRESULT: 0x80072035)"
> > At line:1 char:28
> > + $group.psbase.commitchanges( <<<< )
>
> > However I think this is an error with permissions/security on the PDC
>
> > On Jan 4, 7:57 pm, "Tom G." <thomg...@lycos.com> wrote:
> > > The groupDN variable must contain a string formatted like the
> > > following: "LDAP://CN=test group,OU=SomeOU,DC=foo,DC=bar,DC=com"
>
> > > Tom G.
> > > --
>
> > > char1iecha1k wrote:
> > > > here is what i get when i do that
>
> > > > PS C:\> $groupdn
>
> > > > distinguishedName
> > > > -----------------
> > > > {CN=test group,CN=Users,DC=foobar,DC=co,DC=uk}
>
> > > > PS C:\> $clientdn
>
> > > > distinguishedName
> > > > -----------------
> > > > {CN=test pc,OU=XPClients,DC=foobar,DC=co,DC=uk}
>
> > > > PS C:\> $group = new-object
> > > > System.DirectoryServices.DirectoryEntry($groupDN)
>
> > > > New-Object : Exception calling ".ctor" with "1" argument(s): "The
> > > > value provided for adsObject does not implement IADs.
> > > > "
> > > > At line:1 char:20
> > > > + $group = new-object <<<<
> > > > System.DirectoryServices.DirectoryEntry($groupDN)
>
> > > > On Jan 4, 6:55 pm, "Tom G." <thomg...@lycos.com> wrote:
> > > > > I usually do it like this.
>
> > > > > $group = new-object
> > > > > System.DirectoryServices.DirectoryEntry($groupDN)
> > > > > $group.psbase.properties["member"].remove($userDN)
> > > > > $group.psbase.commitChanges()
>
> > > > > Tom G.
> > > > > --
>
> > > > > char1iecha1k wrote:
> > > > > > Hi,
>
> > > > > > I can add a computer object to an AD group using this method:
>
> > > > > > $Group =
> > > > > > ([ADSI]"LDAP://pdc/CN=TestGroup,DC=foobar,DC=co,DC=uk")
> > > > > > $Client =
> > > > > > ([ADSI]"LDAP://pdc/CN=TestClient,OU=XPClients,DC=foobar,DC=co,DC=u
> > > > > > k") $Group.member += $Client.distinguishedName
> > > > > > $Group.psbase.CommitChanges()
>
> > > > > > But how would I remove it again? when I try this:
>
> > > > > > $Group.member -= $Client.distinguishedName
>
> > > > > > it gives this error
>
> > > > > > Method invocation failed because
> > > > > > [System.DirectoryServices.PropertyValueCollection] doesn't
> > > > > > contain a method named 'op_
> > > > > > Subtraction'.
> > > > > > At line:1 char:17
> > > > > > + $Group.member -= <<<< $Client.distinguishedName