# Collect Inactive AD Users in Variable #
$FDate = Get-Date -Format dd-MM-yyyy # Date variable that is used to make up part of the exported filename's # $Today = Get-Date -Format 'dd MMMM yyyy' # Date variable that is used in the Email Subject and Body # $DDate = Get-Date -Format 'dd/MM/yyyy' # Date variable that is used when populating the 'Description' field in Active Directory # $Date = (Get-Date).AddDays(-30) # Date variable used to calculate accounts that have been inactive for 30 days or more # If not only the Disabled Users report gets sent.
Added a query to check if the VIP Inactive Users report is generated. Created Functions to tidy up actions carried out by the script. # telling the VE-OSS-Leads that there aren't any inactive accounts for today. If there are 0 inactive users an email gets sent Added a query to check how many inactive accounts there are before Mailbox checking functionality has been removed.
# will avoid users that are actively using Outlook/Skype being disabled. Added functionality to check the users mailbox for activity in the last 30 days. # Description: This script will disable all AD Users that haven't logged on for 30 days or more.