<#.SYNOPSIS<A brief description of the script>.DESCRIPTION<The script gathers Domain Admin members and emails them to users specified in the script with an HTML formatted email.>.PARAMETER <paramName><None required>.EXAMPLE<Get-DomainAdminMembers.ps1>#># Import Module of Active DirectoryImport-Module -Name ActiveDirectory$today = (Get-Date).ToString()# Html$a = "<style>"$a = $a + "BODY{background-color:Lavender ;}"$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"$a = $a + "TH{border-width: 1px;padding: 5px;border-style: solid;border-color: black;background-color:thistle}"$a = $a + "TD{border-width: 1px;padding: 5px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"$a = $a + "</style>"# Email Variables$smtp = "smtp.server.com"$to = "user@domain.com", "user2@domain.com", "user3@domain.com"$from = "Report Sender<report@domain.com>"$subject = "Domain Admin Group Members"# Run Command# Get Domain Admins$Users = Get-ADGroupMember 'domain admins' | select name, samaccountname | ConvertTo-html -Head $a -Body "<H2>Domain Admin Members.</H2>"$body = "Report Date $today ."$body += "`n"$body += $Users$body += "`n"# Send mail - If authentication is needed, you'll need to add those parametersSend-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml
Wednesday, September 11, 2013
Get-DomainAdminMembers
Here is a quick script I created that gathers Domain Admin members and emails this using an HTML formatted message.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment