Share via


Script to determine when local accounts password expires

Question

Wednesday, April 27, 2011 8:19 PM

I have about 5 systems that we cannot put onto a domain that have a few different administrator accounts that need to notified when their passwords are going to expire. Every powershell script that I find that does this uses domain calls and I can't find anything that would be close to doing this on only a local level. Does anyone have any ideas how I would accomplish this? Preferably I'd like this to be a scheduled task on each server that runs through a list of users in a spreadsheet and fills in the password expiration date and if it's within a certain amount of days from that date, to send an email to an email address listed for that user in the spreadsheet. Does this sound plausible?

All replies (4)

Friday, April 29, 2011 4:16 PM

So the script runs, but I can't get it to output anything.


Friday, April 29, 2011 6:33 PM

Thanks man! This seems to do just what I needed!


Thursday, May 24, 2012 1:33 PM

Hi Richard,

I realize this thread is over a year old, but I've some questions about your solution.

1) Why did you choose to use multiple else statements instead of doing elseif?

2) Also, I noticed the else statements are nested, why is that?

Thanks,

MK


Friday, May 25, 2012 4:51 PM

Hi Richard,

I am my questions would suggest, I am very much still learning the ropes in Powershell, and it's great to see folks like yourself posting really useful scripts.

Thank you for your explaination.