-4

With a list of users (I need to take all the users of the domain) , check if they are still part of those groups in the domain:

GROUPS TO CHECK Red Blue Black

r.jara
  • 11
  • 1

1 Answers1

0

As many will tell you here. This site is not a script writing service. We'll assist you with code you've written and where you are having issues, well, as long as you show the errors, but you have to show your work.

Lastly, there are lots of articles, and full samples of such use cases all over the web. Using your favorite search engine and your post title would bring you a good list of them. Heck, using the search box on this site, since you can be sure this is not the first time this has been asked.

Examples:

Powershell : Check if AD User is Member of a Group

$user = "TestUser"
$group = "Domain Admins"
$members = Get-ADGroupMember -Identity $group -Recursive | Select -ExpandProperty Name

If ($members -contains $user) {
      Write-Host "$user exists in the group"
 } Else {
        Write-Host "$user not exists in the group"
}

PowerShell script that uses tokenGroups attribute to check membership in security groups

PowerShell: Get All Group-Membership of One User/Multiple Users

Earlier, I wrote a VBScript which can retrieve and enlist All Group-Membership of a given AD User. You can pass the desired Username as a parameter and execute the VBScript. That's it. The script will do the job and display the result. The same VBScript can be downloaded from h

Get-PSWSUSClientGroupMembership.ps1

postanote
  • 15,138
  • 2
  • 14
  • 25