Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Error with Putex in adding members to a group

Posted on 2010-09-14
2
Medium Priority
?
2,022 Views
Last Modified: 2012-05-10
I have an array of distinguished names that I'm trying to remove from a group and I keep getting this error:

Exception calling "PutEx" with "3" argument(s): "Unspecified error
"
At E:\scripts\spresley\dev_test.ps1:113 char:17
+     $groupObj.PutEx <<<< (4, "Member", $removeMember) #remove members
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvokeTI

The group is a large group (over 2,000 existing members) and I'm trying to remove some members.

 
$groupObj = [ADSI]"LDAP://<domainController>/$groupDN"

#removeMember has some valid DN's to remove.
$groupObj.PutEx(4, "Member", $removeMember)

Open in new window


I'm wondering if I'm running into a problem because the group member size is over 1,500 and if I'll need to replace (2) instead of remove (4) using PutEx.  Any one know what's going on?
0
Comment
Question by:evetsleep
2 Comments
 
LVL 13

Accepted Solution

by:
soostibi earned 2000 total points
ID: 33678004
Is $removemember an array? Even if it has one element, it must be an array, so you should use this:

$groupObj.PutEx(4, "Member", @($removeMember))

Open in new window

0
 
LVL 1

Author Comment

by:evetsleep
ID: 33682464
I had created $removeMember as an array:

$removeMember = @()

However that seems to not have been good enough.  I was able to reproduce the problem and when I put in my code what you suggested it was fixed.  Thanks!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question