Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Error handeling with Remove-QADMemberOf

$
0
0

Hello all,

I have security on me to limit the users who have local admin access on desktop PC's.  I am at the point where I am trying to remove user account from nested Global Groups that are part of the desktop Administrators group.  During this process I have identified 200+ disabled accounts that are still part of these GG.  I am trying to use the Remove-QADMemberOf - RemoveAll option to deal with these users.  The problem is there are Global Groups that I do not own (or have access to manage) so the script fails when I hit a user that is in one of these groups.  I have tried the -ErrorAction SilentlyContinue option but it still fails and dumps out of the script.

I'm looking for help on 1st - how to get the script to not "stop" and 2nd - dump the user name I am working with to an Error Log file so I can follow-up on them afterwards.

Thanks for any help you can provide.

$Users=Get-Content"h:\DisabledUsers.txt"

ForEach ($MyUserin$Users) 

{Try {Remove-QADMemberOf-Identity$MyUser-Removeall-ErrorAction SilentlyContinue}

Catch {return ("Problem with user $MyUser")

}}


Viewing all articles
Browse latest Browse all 8583

Trending Articles