Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Remove multiple users from multiple AD groups

$
0
0

Good afternoon,

First time question, long time reader here.

Rather than explain the back ground of this query I'm just going to throw it out there and hope you wonderful people can help resolve what I assume is probably straight forward.

I have a txt file containing 172 Active Directory groups which I'd like to remove mutiple users from.

I found the following PowerShell command online which works perfectly for single users.

Get-Content C:\RemoveGroups.txt | Foreach-Object -Process { Remove-ADGroupMember -Identity $_ -member "user1" -confirm:$false }

I'd like to do this for multiple users yet I have restrictions in place. I can't read the usernames from a text file. The PowerShell line is generated in Excel thus I'm restricted to one or two lines of code to achieve this.

Anyone have any suggestions? -members "user1", "user2" doesn't work, it reads the line as "user1 user2" instead.

With greatest regards
Graham


Viewing all articles
Browse latest Browse all 2562

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>