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
Solved

Compare group membership from two AD accounts with Powershell

Posted on 2014-04-10
4
4,763 Views
Last Modified: 2014-04-10
Hi EE

Anyone have a script that will compare the group membership from two accounts in active directory ?

Compare account A from account B and tell me the groups missing from account A
0
Comment
Question by:MilesLogan
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Sean
ID: 39991682
$a= Get-ADGroupMember GroupA
$a | Select name

$b = Get-ADGroupMember GroupB
$b| Select name

compare-object $a $b

You could easily turn this into a script.
0
 
LVL 2

Author Comment

by:MilesLogan
ID: 39991695
Hi Zindel1 .. I am needing to compare two accounts .. not groups ..
0
 
LVL 9

Accepted Solution

by:
Sean earned 500 total points
ID: 39991730
Sorry - will still be the same idea only use Get-ADPrincipalGroupMembership in place of Get-ADGroupMember

so -

$a = Get-ADPrincipalGroupMembership -Identity Username
$b = Get-ADPrincipalGroupMembership -Identity Username
compare $a $b
0
 
LVL 2

Author Closing Comment

by:MilesLogan
ID: 39991804
Zindel1 thanks !!
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
In-place Upgrading Dirsync to Azure AD Connect
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

809 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