This is an updated version of one of my old scripts - http://portal.sivarajan.com/2011/04/list-local-administrator-group-members.html based on the discussion in the http://sivarajan.com/forum/viewthread.php?tid=59 thread.
This updated script
- Searches Active Directory (Search_AD function) and collects the computer object information. This information will be stored in the C:\Scripts\Servers.csv file.
- 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.
- 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:
- www.sivarajan.com - http://www.sivarajan.com/scripts/Search_AD_Local_Admin_Email.txt
- Microsoft TechNet Gallery - http://gallery.technet.microsoft.com/scriptcenter/Search-AD-Collect-Local-9952be71