工作当中需要查看本地组成员信息,从网上看到使用net localgroup 命令可以实现本地组成员信息,经过再加工得到如下信息,备忘至此!
$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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。