Solved

Remove-QADGroupMember Giving Invalid URI Error On Only Some Groups

Posted on 2012-04-09
8
979 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 5

Expert Comment

by:kollenh
ID: 37824731
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
ID: 37825094
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
ID: 37825179
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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 1

Author Comment

by:Cacophony777
ID: 37825546
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
 
LVL 5

Expert Comment

by:kollenh
ID: 37825574
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
ID: 37829183
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
ID: 37829207
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
ID: 37848009
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
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…
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 antispam), the admini…

733 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