Solved

Remove-QADGroupMember Giving Invalid URI Error On Only Some Groups

Posted on 2012-04-09
8
971 Views
Last Modified: 2012-04-15
I am working on writing a script to automate some of the Active Directory tasks we perform when a user leaves our organization. One of those tasks is removing the user from all groups except "Domain Users." Here is a snippet of that code:
$AllGroups = Get-QADMemberOf $User
Foreach ($Group in $AllGroups)
{
	If ($Group -ne "Domain Users")
	{
		$null = Remove-QADGroupMember $Group -Member $User
		Write-Host "Removed $User from group: $Group ..."
	}
}

Open in new window

The problem is that for a select handful of groups this isn't working (it works great for most). I get this error:
Remove-QADGroupMember : Invalid URI: The hostname could not be parsed.
+ Remove-QADGroupMember <<<<  'ALL EXCH USERS' -Member mscruz
    + CategoryInfo          : NotSpecified: (:) [Remove-QADGroupMember], UriFormatException
    + FullyQualifiedErrorId : System.UriFormatException,Quest.ActiveRoles.ArsPowerShellSnapIn.Commands.RemoveGroupMemberCmdlet2

Open in new window

I have made sure that I have rights to these groups and have verified that I can make the same change manually in Active Directory.

Any Ideas?

Thanks,
-Al
0
Comment
Question by:Cacophony777
  • 4
  • 4
8 Comments
 
LVL 5

Expert Comment

by:kollenh
Comment Utility
I suspect it has to do with the type of group.  If you look at those that have given you a problem, do you see a common thread?  Also, do you have a single-domain environment or multi-?
0
 
LVL 1

Author Comment

by:Cacophony777
Comment Utility
Single Domain environment. What's weird is I have compared the group in the example above with a couple groups that I confirmed the script did work on and they all had the same security and all had the Group Scope set to Universal and Group Type as Security.

The line in the error that states "UriFormatException" leads me to believe that something is pulling over nice from the Get-QADMemberOF cmdlet. Only thing is, even if I just run  (Remove-QADGroup 'ALL EXCH USERS' -Member mscruz) on the command line I get the same error and that Syntax looks correct to me...
0
 
LVL 5

Expert Comment

by:kollenh
Comment Utility
I'm assuming your message above should have been "Remove-QADGroupMember" otherwise that is your problem..

Remove-QADGroupMember wants the DN of the group, so maybe try passing that explicitly?  In the script you'd use $group.dn
0
 
LVL 1

Author Comment

by:Cacophony777
Comment Utility
Yea... That was a typo.

Just tried using the DN when running the command and I'm getting the same result:
Remove-QADGroupMember : Invalid URI: The hostname could not be parsed.
At line:1 char:22
+ Remove-QADGroupMember <<<<  -identity 'CN=ALL EXCH USERS,OU=Distribution Lists,OU=COMHS,dc=*****,dc=***' -Member mscr
uz
    + CategoryInfo          : NotSpecified: (:) [Remove-QADGroupMember], UriFormatException
    + FullyQualifiedErrorId : System.UriFormatException,Quest.ActiveRoles.ArsPowerShellSnapIn.Commands.RemoveGroupMemb
   erCmdlet2

Open in new window

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

by:kollenh
Comment Utility
Any chance that is a dynamically-generated DL?  Maybe try echoing out the DN of the group?  Something has to be different about that particular group.
0
 
LVL 1

Accepted Solution

by:
Cacophony777 earned 0 total points
Comment Utility
So I found me a work around.

If I use the MS ActiveDirectory Module (Remove-ADGroupMember) instead of Quest's ActiveRoles Snapin (Remove-QADGroupMember) it works...

I've never used the ActiveDirectory Module mostly because I had been using ActiveRoles with no issue. Is there any advantage to using one above the other?
0
 
LVL 5

Assisted Solution

by:kollenh
kollenh earned 100 total points
Comment Utility
Actually I haven't used the MS module, either.  I'd say if it suits your needs, you're golden.

Sorry, I wasn't much help.
0
 
LVL 1

Author Closing Comment

by:Cacophony777
Comment Utility
Still not sure why I can't get this to work with Quest ActiveRoles, but I do have it working. Thanks to kollenh for the assistance. I still gave you some points for your time. :-)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now