Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. $accountnames=foreach( $line in (net user) -split "`n"){if($line -ne "" -and $line -notlike 'User accounts*' -and $line -notlike '---------*' -and $line -notlike 'The command completed*' ){ Write-Output $line}}
  2.  
  3. $accountnames=$accountnames -replace("`n|`r|\s+", ",") -split(",")
  4. $account_localgroups=foreach($account in $accountnames){if($account -ne ""){foreach($line in (net user $account)){if($line -like "Local Group Memberships*"){write-output "$account=$line`n".replace("\s+", " ").replace("*", "").replace("Local Group Memberships", "")}}}}
  5.  
  6. write-output $account_localgroups|ConvertFrom-StringData
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement