Created
May 25, 2022 16:18
-
-
Save ScriptingPro/a731145bdb4ba00e547482c8d4385c57 to your computer and use it in GitHub Desktop.
get local group members powershell remote computer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS C:\Windows\system32> $htVmDatacenters.Values | %{ | |
Get-WmiObject -ComputerName $_.Replace("`$", '') -Query "SELECT * FROM Win32_GroupUser" | ?{([WMI]$_.GroupComponent).Caption -like "*\Administrators"} | %{ | |
$PartComponent = $_.PartComponent -replace "^.*\\cimv2:","Class=" -replace '"','' -replace "[\.,]",[environment]::NewLine | ConvertFrom-StringData | |
[PSCustomObject]@{ | |
LocalGroup = ([WMI]$_.GroupComponent).Caption | |
Member = "$($PartComponent.Domain)\$($PartComponent.Name)" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment