title: How to get the get-ADPrincipalGroupMembership for all users in a txt or csv file and put into a txt file for each user?
body: <p>I am trying to get a file with the group-memberships for every user that is specified in a txt/csv file.
  so this is what i had before:</p>
  <pre><code>Get-ADPrincipalGroupMembership -Identity $user -Server $DC | Select name | Where-Object name -like GUSR_* | Out-File &quot;C:\temp\$user.txt&quot; 
  </code></pre>
  <p>this work fine for getting the groups from 1 singel user, but now i have to do this for 100+ users.
  And instead of doing it one by one i am looking for a way to automate it.</p>
  <p>so i got myself a .csv export of all the users i want this done for.
  and started trying.</p>
  <p>what i came up with so far:</p>
  <pre><code>$users = Get-Content &quot;C:\temp\test.csv&quot; |ForEach-Object  {Get-ADPrincipalGroupMembership -Identity $users -Server $DC | Select name | Where-Object name -like GUSR_* | Out-File &quot;\\ads.net\ADS\SDL\Temp\_ROLAND\RSD\test2\$users.txt&quot;}
  </code></pre>
  <p>This cleary doesnt work.
  I have tried a couple of other things with the foreach command but nothing did the trick.
  I have the feeling i am not on the right path to get my result.
  Maby somebody has done this before and can help me get on the right path.
  i'm not new to powershell but i'm far from an expert, most of the time i use it for basic singel commands or edit some great scripts i find.
  sadly for this i haven't found any yet.</p>
  <p>with kind regards
  Roland</p>