获取当前用户的所在组
[System.Security.Principal.WindowsIdentity]::GetCurrent().Groups |%{$_.value} | ForEach-Object { $sid = $_ $objSID = New-Object System.Security.Principal.SecurityIdentifier($sid) $objUser = $objSID.Translate( [System.Security.Principal.NTAccount]) $objUser.Value }
OR
[System.Security.Principal.WindowsIdentity]::GetCurrent().Groups | foreach { $objSID = New-Object System.Security.Principal.SecurityIdentifier($_.value) $objUser = $objSID.Translate( [System.Security.Principal.NTAccount]) $objUser.Value }