Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Check accounts which will Expire soon

Posted on 2013-06-11
6
316 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Find out what you should include to make the best professional email signature for your organization.
In this video we show how to create a mailbox database 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 >> Data…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

860 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