Solved

Check accounts which will Expire soon

Posted on 2013-06-11
6
319 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
[X]
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
  • 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
Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In-place Upgrading Dirsync to Azure AD Connect
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

738 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