Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. $computerName = "MyPC"
  2.  
  3. $computer = [ADSI]"WinNT:// $computerName,computer"
  4.  
  5. $computer.psbase.children | where { $_.psbase.schemaClassName -eq 'group' } | foreach {
  6.  
  7. write-host "Group:" $_.Name
  8.  
  9. write-host "Descr:" $_.Description
  10.  
  11. write-host "-----"
  12.  
  13. $group =[ADSI]$_.psbase.Path
  14.  
  15. $group.psbase.Invoke("Members") | foreach {
  16.  
  17. $ADSIName = $_.GetType().InvokeMember("AdsPath", 'GetProperty', $null, $_, $null)
  18.  
  19. if ($ADSIName -match "[^/]/[^/]") {
  20.  
  21. [String]::Join("", $ADSIName.Split("/")[-2..-1])
  22.  
  23. }
  24.  
  25. else {
  26.  
  27. $ADSIName.Split("/")[-1]
  28.  
  29. }
  30.  
  31. }
  32.  
  33. write-host
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement