<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">MakeITEasy</title><subtitle type="html" /><id>http://blogs.technet.com/b/makeiteasy/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/makeiteasy/" /><link rel="self" type="application/atom+xml" href="http://blogs.technet.com/b/makeiteasy/atom.aspx" /><generator uri="http://telligent.com" version="5.6.50428.7875">Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><updated>2012-11-23T17:51:00Z</updated><entry><title>Active Directory Accidental Deletion - Prevention &amp; Cure</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/makeiteasy/archive/2013/01/14/active-directory-accidental-deletion-prevention-amp-cure.aspx" /><id>http://blogs.technet.com/b/makeiteasy/archive/2013/01/14/active-directory-accidental-deletion-prevention-amp-cure.aspx</id><published>2013-01-14T19:05:00Z</published><updated>2013-01-14T19:05:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Accidental deletions in active directory can cause havoc and unfortunately in the past I was in the middle of one such catastrophic event. It resulted in 4000 odd servers and client machines part of an OU to be deleted and the cause was found to be some housekeeping software. Such accidental deletions can be most destructive in critical industries like banking, financial and public sector organizations. This may have been avoided and secondly could have been fixed in less than 10 % of the actual time spent if the environment was using one of the latest features that we included in Windows 2008 R2 ( &lt;a href="http://technet.microsoft.com/en-us/library/dd392261(v=ws.10)"&gt;Active Directory Recycle Bin&lt;/a&gt; ). Most critical situations arise due to accidental human /tool interference or configuration and it is important to be able to come out of such situations within minimal down time, &lt;strong&gt;Accidental&lt;/strong&gt; &lt;strong&gt;Deletion&lt;/strong&gt; in Active Directory is one such situation. Below are preventions and recovery methods caused due to accidental deletions in Active Directory.&amp;nbsp; Some of the preventive measures are listed below and also links to recovery from such catastrophe with minimal downtime.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;Prevention&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;Preventing Unwanted/Accidental deletions and Restore deleted objects in Active Directory&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/b/abizerh/archive/2009/06/09/preventing-unwanted-accidental-deletions-and-restore-deleted-objects-in-active-directory.aspx"&gt;http://blogs.technet.com/b/abizerh/archive/2009/06/09/preventing-unwanted-accidental-deletions-and-restore-deleted-objects-in-active-directory.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;Windows Server 2008 Protection from Accidental Deletion&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/b/industry_insiders/archive/2007/10/31/windows-server-2008-protection-from-accidental-deletion.aspx"&gt;http://blogs.technet.com/b/industry_insiders/archive/2007/10/31/windows-server-2008-protection-from-accidental-deletion.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;Recovery with minimal downtime&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;The AD Recycle Bin: Understanding, Implementing, Best Practices, and Troubleshooting&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/b/askds/archive/2009/08/27/the-ad-recycle-bin-understanding-implementing-best-practices-and-troubleshooting.aspx"&gt;http://blogs.technet.com/b/askds/archive/2009/08/27/the-ad-recycle-bin-understanding-implementing-best-practices-and-troubleshooting.aspx&lt;/a&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;Windows Server 2008 R2 Quick Look&amp;nbsp; - Active Directory Recycle Bin ~ video&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/windowsserver/ee895053"&gt;http://technet.microsoft.com/en-us/windowsserver/ee895053&lt;/a&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.technet.com/b/makeiteasy/archive/2013/01/14/active-directory-accidental-deletion-prevention-amp-cure.aspx"&gt;(Please visit the site to view this video)&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;AD Recycle Bin &amp;ndash; Step By Step Guide &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/library/dd392261(v=ws.10)"&gt;http://technet.microsoft.com/en-us/library/dd392261(v=ws.10)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp; This is definitely a feature that can save you from nightmares.&lt;/span&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;P.S: IT Environments who are already on Windows 2008 R2 Forest Functional Level require the most minimal configuration changes to enable AD Recycle Bin. Once done you can use the Active Directory recycle bin UI in windows 8 /2012 by installing the RSAT tools on a domain joined windows 8 or windows 2012 server. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/6888.ADCR.png"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/6888.ADCR.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;Its about time you had this feature enabled !&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3545756" width="1" height="1"&gt;</content><author><name>JR_MS</name><uri>http://blogs.technet.com/jratms_4000_live.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>KDC_ERR_PREAUTH_REQUIRED vs. KDC_ERR_PREAUTH_FAILED</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/makeiteasy/archive/2013/01/14/kdc-err-preauth-required-vs-kdc-err-preauth-failed.aspx" /><id>http://blogs.technet.com/b/makeiteasy/archive/2013/01/14/kdc-err-preauth-required-vs-kdc-err-preauth-failed.aspx</id><published>2013-01-14T16:44:00Z</published><updated>2013-01-14T16:44:00Z</updated><content type="html">&lt;p class="Publishwithline"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I often seen network admins look at a network trace and say we have a lot of authentication failures and point to the error &amp;ndash; KDC_ERR_PREAUTH_REQUIRED. I have spent time educating on why this is not an authentication failure but instead the default behavior. The &lt;/span&gt;&lt;/span&gt;&lt;a href="http://technet.microsoft.com/en-us/library/cc734104(v=WS.10).aspx"&gt;&lt;span style="color: #0563c1; font-family: Calibri; font-size: small;"&gt;KDC&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt; (Key Distribution Center) requires all accounts to use pre-authentication. However, pre-authentication can be disabled for individual accounts when necessary for compatibility with other implementations of the protocol. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;How to disable pre-authentication?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;If the box &lt;strong&gt;&amp;ldquo;Do not require Kerberos pre-authentication&amp;rdquo;&lt;/strong&gt; was checked on the user account properties then we would never see the error &lt;strong&gt;&amp;ldquo;KDC_ERR_PREAUTH_REQUIRED&amp;rdquo; &lt;/strong&gt;message in a trace.&lt;strong&gt;&amp;nbsp; &lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;Let us look at the initial user authentication process using network traces.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;FRAME 1:&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/8547.kdcf1.JPG"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/8547.kdcf1.JPG" alt="" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;The above Frame shows you an AS_Request being sent to the domain controller - 192.168.1.25 from Client machine 192.168.1.25. As you observe there is nothing sent along with PaData.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;As a result the DC replies with the below error in the below frame &amp;ndash; KDC_ERR_PREAUTH_REQUIRED.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;FRAME 2:&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/1641.kdcf2.JPG"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/1641.kdcf2.JPG" alt="" border="0" /&gt;&lt;/a&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;So the client then sends the AS_REQUEST again with the pre-authentication data as show in the below frame. &amp;ndash; KrbEncTimestamp: Encrypted Time Stamp Pre-Authentication.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;FRAME 3:&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/8461.kdcf3.JPG"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/8461.kdcf3.JPG" alt="" border="0" /&gt;&lt;/a&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;FRAME 4:&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/3240.kdcf4.JPG"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/3240.kdcf4.JPG" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;As see above the KDC_ERR_PREAUTH_REQUIRED is not exactly an authentication failure. If the Kerberos authentication fails (for example bad password) then you would see &amp;ldquo;KDC_ERR_PREAUTH_FAILED&amp;rdquo; in the trace as shown below.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;FRAME 5: &lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Below is the error you will see in a trace when Authentication fails for the user &amp;ndash; Now it&amp;rsquo;s time you investigate. &lt;/span&gt;J&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;Enable &lt;/span&gt;&lt;a href="http://technet.microsoft.com/en-us/library/bb742435.aspx"&gt;&lt;span style="color: #0563c1; font-family: Calibri; font-size: small;"&gt;Auditing&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;, and Kerberos logging if required.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/1200.kdcf5.JPG"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/1200.kdcf5.JPG" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;I hope its better understood now and there is enough clarity now when you look at network captures that shows &lt;strong&gt;KDC_ERR_PREAUTH_REQUIRED &amp;amp; KDC_ERR_PREAUTH_FAILED &lt;/strong&gt;frames in network traces.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3545721" width="1" height="1"&gt;</content><author><name>JR_MS</name><uri>http://blogs.technet.com/jratms_4000_live.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Auto-Mail Expiring Domain Accounts </title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/makeiteasy/archive/2012/11/23/auto-mail-expiring-domain-accounts.aspx" /><link rel="enclosure" type="application/octet-stream" length="1349" href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-03-53-43-28/Email_2D00_ExpiringADAccounts.ps1" /><id>http://blogs.technet.com/b/makeiteasy/archive/2012/11/23/auto-mail-expiring-domain-accounts.aspx</id><published>2012-11-23T13:51:00Z</published><updated>2012-11-23T13:51:00Z</updated><content type="html">&lt;p class="Publishwithline"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I was looking online for automating the task of domain account expiry notification for one my customers to provide as a reference and found a few which were using quest based PowerShell scripts. The customer required this due to a large number of outsourced business partners in their ecosystem.&amp;nbsp;At the moment the&amp;nbsp;domain accounts given to partner employees working at their different branch offices were valid only for 6 months after which it was to be renewed after approval from the business leads and HR. They wanted a process in which the end user ( partner employees ) were notified via an automated email mentioning the date when their account was to expire and a brief summary of the process to have it extended.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Here is when I thought I could use&amp;nbsp;the power of&amp;nbsp;PowerShell.&amp;nbsp;Many online resources took me&amp;nbsp;through using&amp;nbsp;Quest based cmd-lets and then I used the same ideas but with built-in cmd-lets to&amp;nbsp;do the same job.&lt;/p&gt;
&lt;p&gt;There are 2 phases I planned to tackle this&lt;/p&gt;
&lt;p&gt;1. Build a PowerShell script to find all domain accounts expiring within a specified time ( no. of days ).&lt;/p&gt;
&lt;p&gt;2. Schedule a task to run the Power Shell script once every x no. of days based on the requirement.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Phase 1 : Power Shell script&lt;/p&gt;
&lt;p&gt;######Script Begins Here&lt;/p&gt;
&lt;p&gt;#####Author: Jithesh Raj&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;import-module Activedirectory&lt;/p&gt;
&lt;p&gt;#If you are using Windows 8 or server 2012 you do not require to import-modules as PS 3.0 will do that for you automatically.&lt;/p&gt;
&lt;p&gt;Search-ADAccount -AccountExpiring -TimeSpan 30.00:00:00 | Export-csv "C:\scripts\users.csv"&lt;/p&gt;
&lt;p&gt;#Please change the no. of days in -TimeSpan switch to find all users whose account will expiry in that many days&lt;/p&gt;
&lt;p&gt;import-csv "C:\Scripts\users.csv" | Get-ADUser -Identity {$_.Samaccountname} -Properties displayname,mail,samaccountname,userprincipalname,AccountExpirationDate | Select-Object Name,Samaccountname,Mail,displayname,AccountExpirationDate |ForEach-Object {&lt;/p&gt;
&lt;p&gt;# Variables defined below must be changed in your environment accordingly.&lt;/p&gt;
&lt;p&gt;$smtp= "mail.contoso.com" # Enter your smtp server&lt;/p&gt;
&lt;p&gt;$from= "IThelpdesk@contoso.com" # Enter your from address&lt;/p&gt;
&lt;p&gt;$subject= "Account Expiry Notification" # Enter your email subject&lt;/p&gt;
&lt;p&gt;$email= $_.mail&lt;/p&gt;
&lt;p&gt;$name= $_.displayname&lt;/p&gt;
&lt;p&gt;$date= $_.AccountExpirationDate&lt;/p&gt;
&lt;p&gt;Function GetMsgBody {&lt;/p&gt;
&lt;p&gt;Write-Output @"&lt;/p&gt;
&lt;p&gt;&amp;lt;p&amp;gt;Dear $name,&amp;lt;/p&amp;gt;&lt;/p&gt;
&lt;p&gt;Your windows account is going to expire on $date.&amp;lt;br/&amp;gt;&lt;/p&gt;
&lt;p&gt;Kindly contact your business lead to request for extension.&amp;lt;br/&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;br/&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;br/&amp;gt;&lt;/p&gt;
&lt;p&gt;Kind Regards,&amp;lt;br/&amp;gt;&lt;/p&gt;
&lt;p&gt;IT Helpdesk&lt;/p&gt;
&lt;p&gt;"@&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;[string]$body= GetMsgBody&lt;/p&gt;
&lt;p&gt;&amp;nbsp;# Please change the body of the mail accordingly&lt;/p&gt;
&lt;p&gt;#Execute PowerShell's Send-MailMessage Function&lt;/p&gt;
&lt;p&gt;Send-MailMessage -BodyAsHtml:$true -Body $body -To $email -From $from -SmtpServer $smtp -Subject $subject&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Send-MailMessage -To DomainsHelpdesk@contoso.com -From IThelpdesk@contoso.com -Smtpserver $smtp -attachment "C:\Scripts\users.csv" -subject $Subject&lt;/p&gt;
&lt;p&gt;# Last line sends an additional email to the domains helpdesk team to track the accounts that are expiring for hosusekeeping purposes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;##################################Script Ends Here&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; The above lines of script starting&amp;nbsp;can&amp;nbsp;be copied to a notepad and saved as Email-Expiring-Accounts.ps1 to the machine from where the script is to be run.&lt;br /&gt; &lt;br /&gt; Phase 2: Scheduling the script&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;strong&gt;How to Schedule the script to run using Task Scheduler&lt;/strong&gt;&lt;br /&gt; &lt;br /&gt; 1.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Logon to machine to schedule the task from.&lt;br /&gt; &lt;br /&gt; 2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create a Folder by name C:\scripts since it is used in the script. If you chose to use an alternate location please change it in the script as well. The script obtained from above steps must be copied to this folder.&lt;br /&gt; &lt;br /&gt; 3.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start Task Scheduler&lt;br /&gt; &lt;br /&gt; 4.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Right Click Task Scheduler Library and create a New Folder by&amp;nbsp;Email-Expiring-Accounts.&lt;/p&gt;
&lt;p&gt;5.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You may also create an additional folder by name Active Directory to simply the script based on technology if you may have additional script in the future.&lt;br /&gt; &lt;br /&gt; 6.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Right click to create a new task&lt;br /&gt; &lt;br /&gt; 7.&amp;nbsp; The task will look as below. Additional details can be populated in the description field.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/6153.EM_5F00_EXP_5F00_ACCT2.jpg"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/6153.EM_5F00_EXP_5F00_ACCT2.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;8. Click on the Triggers tab and configure accordingly. This task is configured to run every week on Sunday at 7 AM local time on the server.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/4578.EM_5F00_EXP_5F00_ACCT4.jpg"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/4578.EM_5F00_EXP_5F00_ACCT4.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;9.&amp;nbsp; The &lt;strong&gt;Action&lt;/strong&gt; of the Scheduled Task is to run the following command:&lt;/p&gt;
&lt;ul&gt;
&lt;ul&gt;&lt;ol start="1"&gt;
&lt;li&gt;Program/script:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Add arguments:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;-command "&amp;amp; ' C:\Scripts\Email-Expiring-Accounts.ps1'"&lt;/li&gt;
&lt;/ul&gt;
&lt;/ol&gt;&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/2664.EM_5F00_EXP_5F00_ACCT5.jpg"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-96-93/2664.EM_5F00_EXP_5F00_ACCT5.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;Now the script is ready to run and will automatically send an email using the account specified in the script to individual users whose account is set to expire in the next 30 days. The schedule task can be run using a local administrator account on the machine it is being run from and does not need any domain wide elevated privileges. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt; The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3534328" width="1" height="1"&gt;</content><author><name>JR_MS</name><uri>http://blogs.technet.com/jratms_4000_live.com/ProfileUrlRedirect.ashx</uri></author><category term="automail" scheme="http://blogs.technet.com/b/makeiteasy/archive/tags/automail/" /><category term="Email Notification" scheme="http://blogs.technet.com/b/makeiteasy/archive/tags/Email+Notification/" /><category term="Domain Account Expiry Notification" scheme="http://blogs.technet.com/b/makeiteasy/archive/tags/Domain+Account+Expiry+Notification/" /><category term="automate email notification" scheme="http://blogs.technet.com/b/makeiteasy/archive/tags/automate+email+notification/" /></entry></feed>