Powershell – List Users in Local Administrators Group

The following script lists all users in the local administrators group for all windows servers in the domainCouple of things:

  1. Get-ADComputer cmdlet can change to filter whatever you want. In my case I had 600 servers I wanted to check, but you could do windows 7 workstations just the same
  2. The Computer you are scanning needs to be turned on!
  3. No need to test-connection to check if the computer is on as the ADSI call errors quickly
  4. As it is an ADSI call it just errors automatically , as it is not a cmdlet (so no -erroraction stop parameter required for the try /catch function)
  5. I am using a try/catch so that even if the computer is not turned on, you still get output to the CSV

 

 

Leave a comment

Your email address will not be published. Required fields are marked *