Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $computerName = "MyPC"
- $computer = [ADSI]"WinNT:// $computerName,computer"
- $computer.psbase.children | where { $_.psbase.schemaClassName -eq 'group' } | foreach {
- write-host "Group:" $_.Name
- write-host "Descr:" $_.Description
- write-host "-----"
- $group =[ADSI]$_.psbase.Path
- $group.psbase.Invoke("Members") | foreach {
- $ADSIName = $_.GetType().InvokeMember("AdsPath", 'GetProperty', $null, $_, $null)
- if ($ADSIName -match "[^/]/[^/]") {
- [String]::Join("", $ADSIName.Split("/")[-2..-1])
- }
- else {
- $ADSIName.Split("/")[-1]
- }
- }
- write-host
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement