I am trying to write a script that will show if a user is part of a set of groups that I specify. What I have been able to do is write a script that will show if a user is part of a single group. When the user is part of the group is shows up like this:
Name
----
User1
User2
If they are not part of the group it shows up blank. I want to be able to search several groups and have the results displayed like this where under "Name" it would be their user ID and under "Group" would be the group that they belonged to:
Name Group
---- ----
User1 Example
User2 Example
If the user is not part of any of the groups, I want for it to display none under group. This is the script that I currently have:
$Group="GroupName" $Path ="C:\temp\ListofUsers.txt" Compare-Object -ReferenceObject (Get-AdGroupMember"$Group"| Select -ExpandPropertySamAccountName) -DifferenceObject (Get-Content$Path) -IncludeEqual| WhereSideIndicator-eq"=="|Select @{Name="Name";Expression={$_.InputObject}}