Facebook
From Sweltering Porcupine, 7 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 89
  1. param([String] $Username=$env:USERNAME)
  2.  
  3. function czyJestWGrupie ([String] $user, [Object] $group){
  4.     foreach ($name in Get-LocalGroupMember -Group $group.Name){
  5.         if ($name.toString() -eq $user){
  6.             return $true
  7.         }
  8.     }
  9.    
  10.     #je┼Ťli nie znajdzie zwraca fa┼ész.
  11.     return $false
  12. }
  13.  
  14. Write-Output("U┼╝ytkownik:")
  15. Write-Output $Username
  16.  
  17. $Username+=$env:USERNAME+""
  18. foreach ($group in Get-LocalGroup) {
  19.     if (czyJestWGrupie $Username $group) {
  20.         Write-Output $group.Name
  21.     }
  22.    
  23.  
  24. }
  25. exit 0