Get the App
SLTechnology News&Howtos  ›  Servers  › 

Powershell gets local group membership information

Shulou Source: shulou.com Published: 2022-06-02 10:18:10 11月17日 Update

Work need to check the local group member information, from the Internet to see that the use of net localgroup command can achieve local group member information, after reprocessing to get the following information, memo so far!

$localgroups = "Administrators", "Remote Desktop Users"

$result = @ ()

Foreach ($group in $localgroups) {

$groupmembers = net localgroup $group

Foreach ($member in $groupmembers) {

If ($member-like "CONTOSO*"-and $member-ne "CONTOSO\ Domain Admins") {

$psobject = New-Object psobject

$psobject | Add-Member-MemberType NoteProperty-Name GroupName-Value $group

$psobject | Add-Member-MemberType NoteProperty-Name Members-Value $member

$result+=$psobject

}

}

}

$result

Tags: Information team members commands so far processing memos work Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux Docker Shulou Information Microsoft