Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Email notification, warn about Account Expiration date

$
0
0

Hi script-geniuses!

We set up bulk users with a csv-file and add an expiration date for all users. I collect the users who's account will expire within 32 days like this:

get-aduser -Properties * -filter *|Where-Object{$_.AccountExpirationdate -ne $null}| Select-Object Name, Description, SamAccountName,@{Name='DaysTilExpiration';Expression={($_.AccountExpirationdate - (get-date)).Days}}  | Where-Object {$_.DaysTilExpiration -le 32}

Now I want to set up this script and run it with a task schedule every week where if the return value is true, if there are any user who's account within (-le 32) shows up, an email goes to the admin who will manually either prolong the account or delete it.

Is this the correct way for this challange?

Run script

If return value is true, mail away! If else, do nothing.


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>