Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Using Quest Powershell to check if users are members of certain groups.

$
0
0

Hi, Im having issues with a script I have written. It dont work and returns nothing. Basically I have a list of users that i am checking to see if they have 2 ad groups. if they have then its recorded in a csv.

Here is my code, any help would be appreciated.

   $textFileContents = Get-Content C:\temp\powershell\users.txt

    $results = @()

    foreach($username in $textFileContents){

    $groups = get-qaduser $username |select -expand memberof 

    if ($groups -match "group2" -and $groups -match "group1"){

        echo $groups | select Identity,Name,LastName | export-csv c:\temp\powershell\users.csv

    }


Viewing all articles
Browse latest Browse all 6937

Trending Articles