Solved

Check accounts which will Expire soon

Posted on 2013-06-11
6
315 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
In this video we show how to create an email address policy 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 Mail Flow…
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…

813 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

15 Experts available now in Live!

Get 1:1 Help Now