-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathEmail-PatchingComputers.ps1
More file actions
46 lines (35 loc) · 1.73 KB
/
Copy pathEmail-PatchingComputers.ps1
File metadata and controls
46 lines (35 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
##################################################################################################################
# Please Configure the following variables....
$smtpServer="mail.altercareonline.net"
$from = "NOREPLY - IT Support <no-reply@altercareonline.net>"
$Recipient = "ITdeptTech@altercareonline.net","rebecca.toomey@altercareonline.net", "blee@altercareonline.net", "sysadmin@altercareonline.net"
#
###################################################################################################################
Import-Module ActiveDirectory
$unstaged = Get-ADComputer -filter * -SearchBase "OU=Patching,OU=TSGE,DC=tsg,DC=ds" | select Name
# Email Subject Set Here
$subject="Please move Computer Objects from Patching OU"
# Email Body Set Here, Note You can use HTML, including Images.
$body ="
<p>Dear Staff,</p>
<p>This is a reminder. There are computers still listed in Patching OU. Computers left in this location are NOT supposed to live here. These computers are... </br>"
$body+="<Table>"
$body+="<tr><th>Computer Name:</th>"
$body+="<th>Last Modified:</th>"
$body+="<th>Object Description:</th></tr>"
Get-ADComputer -filter * -SearchBase "OU=Patching,OU=TSGE,DC=tsg,DC=ds" -Properties * | select Name, modified, description | Sort-Object Name |
% { $Body+="<tr><td>$($_.Name)</td><td>$($_.Modified)</td><td>$($_.Description)</td></tr>" }
$body+="</Table>"
$body+="
<p><br /><br /> Please move these to their proper OU. <br /><br />
<p> </p>
<p>Thanks, </p>
<p>IT Dept Autobot</p>
"
# Send Email Message
if (($unstaged) -ne $null)
{
# Send Email Message
Send-Mailmessage -smtpServer $smtpServer -from $from -to $recipient -subject $subject -body $body -bodyasHTML -priority High -UseSsl
} # End Send Message
# End