Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

How to get local admim members

$
0
0

Hi Guys

  I can use following powershell script to get local admin members , but there was one problem , if any non-resolved SID existed in any local admin group, the script will report a error ,and stop to run, was a way to fix that problem

===========================================

Add-Tyep -AssemblyName System.DirectoryServices.AccountManagement

$ctype = [System.Directory.AccountManagement.ContextType]::Macihne

$contexr = New-Object -TypeName System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList $ctype,$server

$idtype = [System.DirectoryServices.AccontManagement.IdentityType]::samAccountName

$group = [System.DirectoryServices.AccountManagement.GroupPrincipal]::FindByIdentity($context,$idtype,'Administrators')


Viewing all articles
Browse latest Browse all 31638

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>