Monday, October 24, 2011

Search AD, Collect Local Admin Group Info and Generate Email Alert – PowerShell Script

This is an updated version of one of my old scripts - based on the discussion in the thread. 

This updated script

  1. Searches Active Directory (Search_AD function) and collects the computer object information.  This information will be stored in the C:\Scripts\Servers.csv file. 
  2. The second function (Seach_LAdmin) uses  C:\Scripts\Servers.csv file as an input  and collects the Local Administrator Group membership details from these computers.
  3. The third function (Send_Email), generates an email alert with the output file (C:\Scripts\SGroupMemberDetails.csv).




It generates 2 output files – Servers.csv and SGroupMemberDetails.csv.  The Servers.csv contains all computer information from Active Directory (output of Seach_AD function) and SGroupMemberDetails.csv file contains the Local Admin group membership details . 

You will also see the status in the console itself. 


An email alert will be generated with SGroupMemberDetails.csv file (Send_Email function). 


In PowerShell V2, you can use Send-MailMessage cmdlet create an email message:


You can download the script from the following 2 locations:

  1. -
  2. Microsoft TechNet Gallery -


Post a Comment

Popular Posts


Twitter Delicious Facebook Digg Stumbleupon Favorites More