New Scripts in Place – Pretty Excited!

Just wanted to celebrate and thought you guys would appreciate.

Just last week we finally put in two scripts I developed in our environment at work. To give you some background I work on a Windows Admin team that focuses on the Windows Server Environment, Hyper-V, AD, DNS and Citrix, but am pretty much the only one that knows powershell in any great capacity. On top of that, I have really only learned PS over the last year and a half.

The scripts that got put in place as scheduled tasks are as such:

Script 1: UserCleanup

Every morning at 10:00 the script runs and will pull in any users that have been inactive (no logons) in 90 days and have also not reset their password in 90 days. After some exclusions if they meet this criteria, their accounts are backed up to XML, disabled and moved to the Disabled Users OU.

Then it will pull any accounts that have been disabled for more than 30 days. Any accounts that have met that criteria and as well have not had their passwords updated in 30 days as well, they will again be backed up to XML and then deleted.

We also have the AD recycle Bin enabled in case they need to be pulled back fast. This script was needed considering we had about 7000+ accounts that needed to be deleted and 2500+ accounts to be disabled. This was a huge security issue.

Once these are complete, the script emails the results (summary and attached logfile) to us (Windows Admin team), as well as a few others in management. I even was able to create an HTML clean template for the email to make it look really nice.

Script 2: Email Expiring Users Managers

This one runs twice a week. It will pull any users whose accounts are expiring within 15 days and groups them by manager. It will then send an email to that manager notifying them of the expiration and instructions on how to request and extension. Again, nice HTML email.

For any users whose manager is either disabled, doesn’t have a valid email address, or the manager field is blank, it will send that list to HR.

Once again just wanted to say how excited I am that they are in production now! I knew very little about PS starting at this job and I couldn’t imagine not using it every day.

submitted by /u/mryananderson
[link] [comments]

Leave a Reply