Help with checking user groups

Hi!

I’m kinda new to powershell and i have this issue where i try to import users from a text document and then check those users against a group and get a truefalse and have it exported to a csv file

Here is what i come up with so far with some googling and my very basic knowledge.

$textFileContents = Get-Content C:report.txt

foreach($username in $textFileContents){

$User = get-aduser $username $groups = $User | Select -ExpandProperty MemberOf if ($groups -match "vpn_access" ) { $User | select Identity,Name,LastName,memberof | export-csv c:vpnaccess.csv -Append -NoTypeInformation } } 

Would appreciate all the help i could get.

submitted by /u/PM_MEMES_ABOUT_SKELE
[link] [comments]

Leave a Reply