Notification from AD when Account expires

Hi

I have an OU with temporary accounts (i.e. that have expiration dates set in them)

I want AD to alert these users and possibly their manager when their accounts are due to expire (make 2 -3 weeks beforehand)

Anyone know how this can be done?

Thanks
kwatt562Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ben HartCommented:
That's most likely going to recreate 3rd party software..
 Something akin to this: http://www.manageengine.com/products/ad-manager/automated-active-directory-reports/ad-user-account-password-expiration-notification.html

Anything using built-in tools like powershell would have to be manually ran, or setup on a scheduled task.. but then your talking just a powershell script.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ben HartCommented:
Automating this inside a Scheduled task would accomplish part of what your wanting

http://stackoverflow.com/questions/10247334/powershell-find-users-expiring-in-7-days
0
RobSampsonCommented:
Hi, as a logon script, this code would tell the current user when their password is going to expire:
'========================================
' First, get the domain policy.
'========================================
Dim oDomain
Dim oUser
Dim maxPwdAge
Dim numDays
Dim warningDays
warningDays = 14

Set LoginInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & LoginInfo.UserName & "")
strDomainDN = UCase(LoginInfo.DomainDNSName)
strUserDN = LoginInfo.UserName

Set oDomain = GetObject("LDAP://" & strDomainDN)
Set maxPwdAge = oDomain.Get("maxPwdAge")
'========================================
' Calculate the number of days that are
' held in this value.
'========================================
numDays = CCur((maxPwdAge.HighPart * 2 ^ 32) + _
maxPwdAge.LowPart) / CCur(-864000000000)
'WScript.Echo "Maximum Password Age: " & numDays

'========================================
' Determine the last time that the user
' changed his or her password.
'========================================
Set oUser = GetObject("LDAP://" & strUserDN)
'========================================
' Add the number of days to the last time
' the password was set.
'========================================
whenPasswordExpires = DateAdd("d", numDays, oUser.PasswordLastChanged)
fromDate = Date
daysLeft = DateDiff("d",fromDate,whenPasswordExpires)

'WScript.Echo "Password Last Changed: " & oUser.PasswordLastChanged
if (daysLeft < warningDays) and (daysLeft > -1) then

MsgBox "Password Expires in " & daysLeft & " day(s)" & " at " & whenPasswordExpires & chr(13) & chr(13) & "Please change your password. Press CTRL-ALT-DEL and" & chr(13) & "select 'Change a password' option.", VBSystemModal, "PASSWORD EXPIRATION WARNING!"
End if
'========================================
' Clean up.
'========================================
Set oUser = Nothing
Set maxPwdAge = Nothing
Set oDomain = Nothing

Open in new window


Are you after the password expiration, or user account expiration?

For an account expiration, try this one:

Set LoginInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & LoginInfo.UserName & "")
strUserDN = LoginInfo.UserName
Set objUser = GetObject("LDAP://" & strUserDN)
intUAC=objUser.GetEx("userAccountControl")
On Error Resume Next
accountExpires = objUser.AccountExpirationDate
If accountExpires = "1/1/1970" Or Year(accountExpires) = "1601" Or Err.Number = -2147467259 Then
	WScript.Echo "Your account never expires."
Else
	WScript.Echo "Your account expires on " & accountExpires & "(" & DateDiff("d", Now, accountExpires) & " days)"
End If

Open in new window


Regards,

Rob.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.