Solved

Check accounts which will Expire soon

Posted on 2013-06-11
6
312 Views
Last Modified: 2013-06-12
Hello,

i need a script to run it on Active Directory to check accounts which will expire in less than one week to send for them email to contact HR or line manager to renew the accounts.

and if there is a way to send for them email automatically as a notification.

Regards,
0
Comment
Question by:fadyaz
  • 4
  • 2
6 Comments
 
LVL 19

Accepted Solution

by:
helpfinder earned 500 total points
ID: 39239481
checkk this powershell script for passwords expirting whitin defined time

earch-ADAccount -AccountExpiring -TimeSpan "365" | Select-Object Name,AccountExpirationDate | Sort-Object AccountExpirationDate | Export-Csv Expiring-Accounts.csv

Open in new window

0
 
LVL 2

Author Comment

by:fadyaz
ID: 39239493
Thanks helpfinder for your reply.

Does this script will export the account which will expire within 7 days. ?
0
 
LVL 19

Expert Comment

by:helpfinder
ID: 39239499
no, this is for 365 days, just change -TimeSpan value for desired number
0
 
LVL 2

Author Comment

by:fadyaz
ID: 39239537
thanks a lot for your fast reply.  i want to make it as a batch file to just run it once every 7 days.
0
 
LVL 2

Author Comment

by:fadyaz
ID: 39240330
I tried to run the script but it show for me an error message in attachment
error.png
0
 
LVL 2

Author Comment

by:fadyaz
ID: 39240383
I found another script on the internet but it is not working can any body help me to modify it to check the expired account within 7 days.

dsquery * "ou=recipients,ou=exchange,dc=contoso,dc=com" -r -limit 999999 -filter " (&(objectCategory=Person)(objectClass=User)(!accountExpires=9223372036854775807)(!accountExpires=0)(accountExpires<=128947832000000000))"  -attr sAMAccountname displayName > expired.txt

Open in new window


http://gallery.technet.microsoft.com/scriptcenter/Batch-file-to-fine-expired-ddb246d3
0

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now