├── AD-Expiry-Notification ├── AD-Account-Exp-Notify_Message-Body_NL.html ├── AD-Account-Exp-Notify_Message-Body_US.html ├── AD-Exp-Notify.cmd ├── AD-Exp-Notify.ps1 ├── AD-Exp-Notify.xml ├── AD-Exp-Notify_Example-Logs-And-CSVs.zip ├── AD-Pwd-Exp-Notify_Message-Body_NL.html ├── AD-Pwd-Exp-Notify_Message-Body_US.html ├── README.md ├── iamTEC_AccountExpiration_NL.png ├── iamTEC_AccountExpiration_US.png ├── iamTEC_PasswordExpiration_NL.png ├── iamTEC_PasswordExpiration_US.png ├── scheduledTask_Notify Users With Expired Accounts And Or Passwords.xml └── template_IAMTEC.png ├── AD-Schema-Extension-Conflict-Analyzer.ps1 ├── Build-Password-Policy-Config-Report.ps1 ├── Check-AD-Replication-Latency-Convergence.md ├── Check-AD-Replication-Latency-Convergence.ps1 ├── Check-AD-Replication-Latency-Convergence.xml ├── Check-Connectivity-All-DCs-In-AD-Forest.md ├── Check-Connectivity-All-DCs-In-AD-Forest.ps1 ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence.md ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence.ps1 ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence.xml ├── Images ├── Check-AD-Replication-Latency-Convergence_Picture01.png ├── Check-AD-Replication-Latency-Convergence_Picture02.png ├── Check-AD-Replication-Latency-Convergence_Picture03.png ├── Check-AD-Replication-Latency-Convergence_Picture04.png ├── Check-AD-Replication-Latency-Convergence_Picture05.png ├── Check-AD-Replication-Latency-Convergence_Picture06.png ├── Check-AD-Replication-Latency-Convergence_Picture07.png ├── Check-AD-Replication-Latency-Convergence_Picture08.png ├── Check-AD-Replication-Latency-Convergence_Picture09.png ├── Check-AD-Replication-Latency-Convergence_Picture10.png ├── Check-AD-Replication-Latency-Convergence_Picture11.png ├── Check-AD-Replication-Latency-Convergence_Picture12.png ├── Check-AD-Replication-Latency-Convergence_Picture13.png ├── Check-AD-Replication-Latency-Convergence_Picture14.png ├── Check-AD-Replication-Latency-Convergence_Picture15.png ├── Check-AD-Replication-Latency-Convergence_Picture16.png ├── Check-AD-Replication-Latency-Convergence_Picture17.png ├── Check-Connectivity-All-DCs-In-AD-Forest01.png ├── Check-Connectivity-All-DCs-In-AD-Forest02.png ├── Check-Connectivity-All-DCs-In-AD-Forest03.png ├── Check-Connectivity-All-DCs-In-AD-Forest04.png ├── Check-Connectivity-All-DCs-In-AD-Forest05.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture01.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture02.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture03.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture04.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture05.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture06.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture07.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture08.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture09.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture10.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture11.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture12.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture13.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture14.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture15.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture16.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture17.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture18.png ├── Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture19.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture01.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture02.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture03.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture04.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture05.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture06.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture07.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture08.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture09.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture10.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture11.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture12.png ├── OLD_Check-AD-Replication-Latency-Convergence_Picture13.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture01.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture02.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture03.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture04.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture05.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture06.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture07.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture08.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture09.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture10.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture11.png ├── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture12.png └── OLD_Check-SYSVOL-And-DFSR-And-NTFRS-Folders-Replication-Latency-Convergence_Picture13.png ├── LICENSE ├── Managing-ACEs-In-AD-Through-PowerShell.zip ├── README.md ├── Reset-KrbTgt-Password-For-RWDCs-And-RODCs.md ├── Reset-KrbTgt-Password-For-RWDCs-And-RODCs.ps1 ├── Reset-KrbTgt-Password-For-RWDCs-And-RODCs.xml ├── Retrieve-List-Of-Conflicting-Objects.ps1 ├── Scan-And-Check-All-Accounts-In-AD-Forest_01_Basic-Info.ps1 ├── Scan-And-Check-All-Accounts-In-AD-Forest_02_Delegation-Info.ps1 ├── Scan-And-Check-All-Accounts-In-AD-Forest_03_NC-Level-Permissions-Info.ps1 ├── Scan-And-Check-All-Accounts-In-AD-Forest_04_Object-Level-Permissions-Info.ps1 └── Scan-And-Check-All-Accounts-In-AD-Forest_05_Account-And-Password-Hygiene-Info.ps1 /AD-Expiry-Notification/AD-Account-Exp-Notify_Message-Body_NL.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AD-Account-Expiration-Notification_NL 5 | 7 | 8 | 9 |

Verlopen Account

10 |

!!! ATTENTIE | Actie Benodigd !!!

11 |
12 |
13 |

Beste FIRST_NAME,

14 |

Uw account 'PRINCIPAL_ACCOUNT_NAME' in het 'FQDN_DOMAIN' AD domein verloopt op ACCOUNT_EXPIRY_DATE. Wilt u a.u.b. z.s.m. een verzoek indienen om uw account 'PRINCIPAL_ACCOUNT_NAME' te verlengen?

15 |

Om een verlenging aan te vragen voor uw account dient u de volgende stappen te gebruiken:

16 | 19 |

U kunt NIET reageren op dit bericht!

20 |

Bedankt!

21 |

Uw Netwerk Beheerder

22 | 23 | -------------------------------------------------------------------------------- /AD-Expiry-Notification/AD-Account-Exp-Notify_Message-Body_US.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AD-Account-Expiration-Notification_US 5 | 7 | 8 | 9 |

Account Expiration

10 |

!!! ATTENTION | Action Required !!!

11 |
12 |
13 |

Dear FIRST_NAME,

14 |

The account 'PRINCIPAL_ACCOUNT_NAME' in the 'FQDN_DOMAIN' AD domain will expire at ACCOUNT_EXPIRY_DATE. Please request an extension for your AD account 'PRINCIPAL_ACCOUNT_NAME' as soon as possible!

15 |

To request an extension of your account use the following steps:

16 | 19 |

Please DO NOT reply to e-mail message!

20 |

Thanks!

21 |

Your Network Administrator

22 | 23 | -------------------------------------------------------------------------------- /AD-Expiry-Notification/AD-Exp-Notify.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | CLS 3 | COLOR 0E 4 | PowerShell.exe -ExecutionPolicy Bypass -file %0\..\AD-Exp-Notify.ps1 5 | 6 | ECHO. 7 | ECHO FINISHED! -------------------------------------------------------------------------------- /AD-Expiry-Notification/AD-Exp-Notify.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjorz/Public-AD-Scripts/6b73209d696015fdd37e619ae1fbb013c99b0279/AD-Expiry-Notification/AD-Exp-Notify.ps1 -------------------------------------------------------------------------------- /AD-Expiry-Notification/AD-Exp-Notify.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjorz/Public-AD-Scripts/6b73209d696015fdd37e619ae1fbb013c99b0279/AD-Expiry-Notification/AD-Exp-Notify.xml -------------------------------------------------------------------------------- /AD-Expiry-Notification/AD-Exp-Notify_Example-Logs-And-CSVs.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjorz/Public-AD-Scripts/6b73209d696015fdd37e619ae1fbb013c99b0279/AD-Expiry-Notification/AD-Exp-Notify_Example-Logs-And-CSVs.zip -------------------------------------------------------------------------------- /AD-Expiry-Notification/AD-Pwd-Exp-Notify_Message-Body_NL.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AD-Password-Expiration-Notification_NL 5 | 7 | 8 | 9 |

Verlopen Wachtwoord

10 |

!!! ATTENTIE | Actie Benodigd !!!

11 |
12 |
13 |

Beste FIRST_NAME,

14 |

Het huidige wachtwoord van het account 'PRINCIPAL_ACCOUNT_NAME' in het 'FQDN_DOMAIN' AD domein verloopt op PWD_EXPIRY_DATE. Wijzig a.u.b. uw wachtwoord zo snel als mogelijk!

15 |

Het nieuwe wachtwoord moet aan de volgende eisen voldoen:

16 | 23 |

Wanneer wachtwoord complexiteit aan staat, zijn de wachtwoord eisen als volgt:

24 | 36 |

Om uw wachtwoord te wijzigen, opnieuw in te stellen of te registeren voor SSPR, gebruik een van de onderstaande methoden:

37 | 43 |

Geef nooit uw persoonlijke wachtwoord aan derden!

44 |

Wij zullen nooit om uw persoonlijke wachtwoord vragen!

45 |

U kunt NIET reageren op dit bericht!

46 |

Bedankt!

47 |

Uw Netwerk Beheerder

48 | 49 | -------------------------------------------------------------------------------- /AD-Expiry-Notification/AD-Pwd-Exp-Notify_Message-Body_US.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AD-Password-Expiration-Notification_US 5 | 7 | 8 | 9 |

Password Expiration

10 |

!!! ATTENTION | Action Required !!!

11 |
12 |
13 |

Dear FIRST_NAME,

14 |

The current password of the account 'PRINCIPAL_ACCOUNT_NAME' in the 'FQDN_DOMAIN' AD domain will expire at PWD_EXPIRY_DATE. Please change your password as soon as possible!

15 |

The new password must meet the following requirements:

16 | 23 |

If password complexity is enabled, the new password must meet the following requirements:

24 | 36 |

To change/reset your password or register for SSPR use either one of the following steps:

37 | 43 |

Never give out your personal password to anyone!

44 |

We will never ask for your personal password!

45 |

Please DO NOT reply to e-mail message!

46 |

Thanks!

47 |

Your Network Administrator

48 | 49 | -------------------------------------------------------------------------------- /AD-Expiry-Notification/README.md: -------------------------------------------------------------------------------- 1 | # AD Expiration Notification 2 | 3 | ## Social Media Channels 4 | * [Visit my blog](https://jorgequestforknowledge.wordpress.com/) 5 | * [Follow me on twitter](https://twitter.com/JsQForKnowledge/)![](https://twitter.com/favicon.ico) 6 | * [Follow me on facebook](https://www.facebook.com/JorgesQuestForKnowledge/)![](https://facebook.com/favicon.ico) 7 | * [Follow me on linkedin](http://www.linkedin.com/in/jorgedealmeidapinto)![](https://www.linkedin.com/favicon.ico) 8 | 9 | ## Main Features 10 | * **Account Expiration Notification** - Send a notification to the corresponding user when the AD account is about to expire, as the number of days until the account expiration date falls within a defined warn period 11 | * **Password Expiration Notification** - Send a notification to the corresponding user when the password of the AD account is about to expire, as the number of days until the password expiration date falls within a defined warn period 12 | 13 | ## Getting Started 14 | * Determine the notification features to use globally 15 | * Determine the FROM e-mail address, the Test Mode TO e-mail address, the Support TO e-mail afddress and the mail/smtp server 16 | * Determine whatever is applicable the URLs for "Requesting Account Extension", "Changing Password", "Register for Self-Service Password Reset" and "Resetting Password" 17 | * Determine the AD Domains to target and for each AD domain determine if you want a specific DC or want to discover a DC, and within each AD domain which OUs need to be target 18 | * For each targeted OU determine which notification featiure you want to enable or disable and which language template to use 19 | * Determine how many HTML body template files and picture files are needed. Every HTML body template file targets a specific feature AND language. Do not have overlaps! 20 | * Determine the warning periods for every feature you enable 21 | * Determine the AD user account to use to execute the script 22 | * Configure the required AD permissions 23 | * Create the HTML body files and the picture files. See the included examples. The following variables can be used in the subject and/or HTML body files. It is not mandatory to use variables: 24 | * Generic: 25 | * IMAGE_BASE_FILE_NAME 26 | * FQDN_DOMAIN 27 | * NBT_DOMAIN 28 | * FIRST_NAME 29 | * LAST_NAME 30 | * DISPLAY_NAME 31 | * EMAIL_ADDRESS 32 | * UPN 33 | * SAM_ACCOUNT_NAME 34 | * PRINCIPAL_ACCOUNT_NAME 35 | * For accountExpiryNotification only: 36 | * ACCOUNT_EXPIRY_DATE 37 | * ACCOUNT_EXPIRE_IN_NUM_DAYS 38 | * ACCOUNT_EXTENSION_URL 39 | * For pwdExpiryNotification only 40 | * PWD_LAST_SET 41 | * PWD_EXPIRY_DATE 42 | * PWD_EXPIRE_IN_NUM_DAYS 43 | * PWD_MIN_LENGTH 44 | * PWD_MIN_AGE 45 | * PWD_MAX_AGE 46 | * PWD_HISTORY 47 | * PWD_COMPLEX 48 | * PWD_CHANGE_URL 49 | * SSPR_REGISTRATION_URL 50 | * PWD_RESET_URL 51 | * Configure the Windows Server to host and execute the script 52 | * Configure the XML configuration file of the script 53 | * After every is configured: 54 | (**REMARK**: When executing the script check screen output and or LOG files and any CSV files if enabled in the XML file. If users are in scope for notification, the screen output and/or the log file will publish non-zero values for at least one 'User Count Within Warning Period' and 'User Count To Be Notified'. At the same time, the CSV file will contain the list of users that would be notified) 55 | * Execute the PowerShell script manually (using the execution account through RUNAS) WITHOUT the '-force parameter', evaluate results and (re)configure whatever needs to be (re)configured 56 | * Execute the PowerShell script manually (using the execution account through RUNAS) WITH the '-force parameter' and execution mode 'DEV', evaluate results and (re)configure whatever needs to be (re)configured 57 | * Execute the PowerShell script manually (using the execution account through RUNAS) WITH the '-force parameter' and execution mode 'TEST', evaluate results and (re)configure whatever needs to be (re)configured 58 | * Execute the PowerShell script through the scheduled task WITHOUT the '-force parameter', evaluate results and (re)configure whatever needs to be (re)configured 59 | * Execute the PowerShell script through the scheduled task WITH the '-force parameter' and execution mode 'DEV', evaluate results and (re)configure whatever needs to be (re)configured 60 | * Execute the PowerShell script through the scheduled task WITH the '-force parameter' and execution mode 'TEST', evaluate results and (re)configure whatever needs to be (re)configured 61 | * Execute the PowerShell script through the scheduled task WITH the '-force parameter' and execution mode 'PROD', when you are ready to put this in production\ 62 | (**REMARK**: Before running in PROD mode, make sure to notify users that they will start to receive e-mails about account/password expirations! Not doing this may end up in users seeing it as spam or phishing and that may overload the service desk!) 63 | 64 | ## Configuration - Script XML 65 | * The script uses the default 'AD-Exp-Notify.xml' file in the same folder as the PowerShell script. If the parameter '-xmlconfigfilepath' is used with the full path to the XML file, then that will be used instead. 66 | * Enable or disable at global level the notification features you need. By default all features are disabled:\ 67 | (**REMARK**: Notifications will only work if enabled at global level!) 68 | 69 | ```XML 70 | 71 | 72 | 73 | 74 | 75 | 76 | ``` 77 | 78 | * When NOT using the '-force' parameter, the script will always operate in TEST mode with NO mailings at all, no matter what the XML configuration file specifies. Try this first! 79 | * When using the '-force' parameter, the script will operate in the mode specified in the XM configuration file\ 80 | (**REMARK**: When the execitionMode is 'DEV' then the mail address specified in 'toSMTPAddressInTestMode' will receive just 1 mail for every globally enabled feature!)\ 81 | (**REMARK**: When the execitionMode is 'TEST' then the mail address specified in 'toSMTPAddressInTestMode' will receive all mails that would have been send to scoped individual users for every globally enabled feature and if a warn period is matched!)\ 82 | (**REMARK**: When the execitionMode is 'PROD' then the scoped individual users will receive the mail for every globally enabled feature and if a warn period is matched!)\ 83 | 84 | ```XML 85 | 86 | DEV 87 | ``` 88 | 89 | * When sending an e-mail, the following e-mail address is the FROM/SENDER address: 90 | 91 | ```XML 92 | 93 | FROM_XXX@YYY.ZZZ 94 | ``` 95 | 96 | * When sending an e-mail in DEV or TEST mode, the following e-mail address is the TO/RECIPIENT address: 97 | 98 | ```XML 99 | 100 | TO_XXX@YYY.ZZZ 101 | ``` 102 | 103 | * When script encounters a pre-defined issue the following e-mail address is the TO/RECIPIENT address: 104 | 105 | ```XML 106 | 107 | TO_XXX@YYY.ZZZ 108 | ``` 109 | 110 | * When script sends any e-mail the following specified mail/smtp server is used: 111 | 112 | ```XML 113 | 114 | XXX.YYY.ZZZ 115 | ``` 116 | 117 | * When script sends a notification e-mail the following is the priority of that e-mail: 118 | 119 | ```XML 120 | 121 | XXX 122 | ``` 123 | 124 | * When script sends a notification e-mail, depending on the notification type (account expiry notification or password expiry notification) and the language, the correct HTML body file and picture file are determined and used as the mail template: 125 | 126 | ```XML 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | ``` 137 | 138 | * When users receives an e-mail that notifies about upcoming account expiry and in your guidance you want to provide a URL where users can request account extension, the following can be used: 139 | 140 | ```XML 141 | 142 | 143 | https://idmportal.iamtec.net:444/IdentityManagement/ 144 | ``` 145 | 146 | * When users receives an e-mail that notifies about upcoming password expiry and in your guidance you want to provide a URL where users can change their password, the following can be used:\ 147 | (**REMARK**: If you want to use the ADFS Password Change Portal, the URL is 'https:///adfs/portal/updatepassword.aspx')\ 148 | (**REMARK**: If you want to use the Azure AD Password Change Portal, the URL is 'https://account.activedirectory.windowsazure.com/ChangePassword.aspx') 149 | ```XML 150 | 151 | 152 | 153 | https://account.activedirectory.windowsazure.com/ChangePassword.aspx 154 | ``` 155 | 156 | * When users receives an e-mail that notifies about upcoming password expiry and in your guidance you want to provide a URL where users can register for password reset, the following can be used:\ 157 | (**REMARK**: If you want to use the FIM/MIM Registration Portal, the URL is 'https:///'. You must have this portal already in use, and the URL depends on what you configured during it installation)\ 158 | (**REMARK**: If you want to use the combined Azure AD Password Security Info Registration Portal, the URL is 'https://aka.ms/setupsecurityinfo') 159 | ```XML 160 | 161 | 162 | 163 | https://aka.ms/setupsecurityinfo 164 | ``` 165 | 166 | * When users receives an e-mail that notifies about upcoming password expiry and in your guidance you want to provide a URL where users can reset their password, the following can be used:\ 167 | (**REMARK**: If you want to use the FIM/MIM Self-Service Password Reset Portal, the URL is 'https:///'. You must have this portal already in use, and the URL depends on what you configured during it installation)\ 168 | (**REMARK**: If you want to use the Azure AD Password Reset Portal, the URL is 'https://passwordreset.microsoftonline.com/?whr=mydomain.com'. Do not forget to configure the domain at the end of the URL) 169 | ```XML 170 | 171 | 172 | 173 | https://passwordreset.microsoftonline.com/?whr=mydomain.com 174 | ``` 175 | 176 | * When the script executes, a log file is created in the folder specified below. Specify the full path of the folder where log files should be created: 177 | ```XML 178 | 179 | C:\AD-Support\Scripts\AD-Expiry-Notification 180 | ``` 181 | 182 | 183 | * When the script executes, with the following setting it cleans all log files, except the last specified number of log files: 184 | ```XML 185 | 186 | 30 187 | ``` 188 | 189 | * When the script executes, with the following setting you can specify if CSV files should be created or not: 190 | ```XML 191 | 192 | ON 193 | ``` 194 | 195 | * When the script executes, a csv file is created in the folder specified below if export of csv files has been enabled. Specify the full path of the folder where csv files should be created: 196 | ```XML 197 | 198 | C:\AD-Support\Scripts\AD-Expiry-Notification 199 | ``` 200 | 201 | * When the script executes, with the following setting it cleans all csv files, except the last specified number of csv files: 202 | ```XML 203 | 204 | 30 205 | ``` 206 | 207 | * When the script executes, with the following setting you can define a date and time format: 208 | ```XML 209 | 210 | yyyy-MM-dd HH:mm:ss 211 | ``` 212 | 213 | * When the script executes, the following section determines which AD domains to target and in the AD domain which OUs with users to target. For each OU (Search Base) you can specify which feature to use, the language and the search scope to in the query. 'OneLevel' means only that specified OU, and 'Subtree' means the specified OU and any sub OUs if any:\ 214 | (**REMARK**: For every AD domain, you can either list a specific DC through its FQDN to always target or you can specify DISCOVER so that a DC is discovered through the DC locator process. If you list a specific DC, then that DC must be available, otherwise the corresponding AD domain will not be processed)\ 215 | (**REMARK**: Be aware NOT to overlap OUs as users might receive e-mails more than once! The only way to overlap an OU with sub OUs is if you specify the search scope 'OneLevel' for the top level OU and the search scope 'Subtree' for the sub OUs)\ 216 | (**REMARK**: Only enable a feature for an OU/searchBase if it really is needed, otherwise do not enable it)\ 217 | (**REMARK**: accountExpiryNotificationEnabled="true" : enables account expiration notifications for that OU/searchBase)\ 218 | (**REMARK**: accountExpiryNotificationEnabled="false" : disables account expiration notifications for that OU/searchBase)\ 219 | (**REMARK**: pwdExpiryNotificationEnabled="true" : enables password expiration notifications for that OU/searchBase)\ 220 | (**REMARK**: pwdExpiryNotificationEnabled="false" : disables password expiration notifications for that OU/searchBase)\ 221 | (**REMARK**: The language 'code' is used to match the correct HTML body file and picture file) 222 | ```XML 223 | 224 | 225 | 226 | 227 | OU=EMPLOYEES,OU=Org-Users,DC=IAMTEC,DC=NET 228 | OU=Users,OU=EMPLOYEES,OU=Org-Users,DC=IAMTEC,DC=NET 229 | OU=DoesNotExist1,OU=EMPLOYEES,OU=Org-Users,DC=IAMTEC,DC=NET 230 | OU=OU=CONTRACTORS,OU=Org-Users,DC=IAMTEC,DC=NET 231 | OU=Users,OU=OU=CONTRACTORS,OU=Org-Users,DC=IAMTEC,DC=NET 232 | OU=DoesNotExist2,OU=OU=CONTRACTORS,OU=Org-Users,DC=IAMTEC,DC=NET 233 | OU=Users,OU=CONTRACTORS,OU=Org-Users,DC=IAMTEC,DC=NET 234 | OU=Users,OU=CONTRACTORZZZ,OU=Org-Users,DC=IAMTEC,DC=NET 235 | OU=Users,OU=HISTORY1,OU=Org-Users,DC=IAMTEC,DC=NET 236 | OU=Users,OU=HISTORY2,OU=Org-Users,DC=IAMTEC,DC=NET 237 | OU=BLA,OU=Org-Users,DC=IAMTEC,DC=NET 238 | 239 | 240 | DC=TROOT,DC=NET 241 | 242 | 243 | DC=CHLD,DC=IAMTEC,DC=NET 244 | 245 | 246 | ``` 247 | 248 | * When the script executes, and users in specified OUs/searchbases are checked, it will check, per enabled feature if the number days until expiry match a single warn period:\ 249 | (**REMARK**: It is suggested to execute the script on a weekly basis and specify 1 or more warning periods taking a factor of 7 days into account)\ 250 | (**REMARK**: Numbers shown are just examples used for testing and do not take the recommendation of the factor into account)\ 251 | (**REMARK**: Be aware NOT to overlap warning periods) 252 | ```XML 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | ``` 277 | 278 | ## Configuration - Active Directory 279 | ### *Permissions* 280 | * NOT needed to be a member of Domain Admins, Enterprise Admins or any other powerfull AD group/role 281 | * A normal domain user is good enough 282 | * When using the script for notifications due to password expiry, the details of the Password Settings Objects (PSO) in the same AD domain as the targeted users must be read. By default only members of Domain Admins can read the contents of the PSO container. Instead of making the user account executing this script a member of Domain Admins, delegate Allow:Read permissions to that user account, preferrably through a security group if other security principals (e.g. admins, helpdesk, etc) require the same permissions for support and/or troubleshooting. For more information about this see the blog post: https://jorgequestforknowledge.wordpress.com/2007/08/09/windows-server-2008-fine-grained-password-policies/. For ANY AD Domain with users for which password expiry notifications are required, execute the following to delegate: 283 | 284 | ```BATCH 285 | DSACLS "\\\CN=Password Settings Container,CN=System," /G ":GR" /I:T 286 | ``` 287 | * If the account executing the script does not own the mail address specified in the 'mailFromSender' in the XML configuration file, that execution account requires the 'Allow:Send As' permission on the AD account that does own that e-mail address. If the account that owns that e-mail address is also a member of any protected group, either directly or indirectly, you need to assign the 'Allow:Send As' permission on the AdminSDHolder object.\ 288 | (**REMARK**: If the account executing the script does own the mail address, this additional configuration is not needed)\ 289 | (**REMARK**: If you use an (open) internal relay server that authenticates based upon the IP address of the server the script is running on, this additional configuration is not needed)\ 290 | 291 | ```BATCH 292 | For Account: DSACLS "\\\" /G ":CA;Send As" 293 | For AdminDSHolder: DSACLS "\\\CN=AdminSDHolder,CN=System," /G ":CA;Send As" 294 | ``` 295 | 296 | ## Configuration - Windows Server 297 | * NOT needed to run on a domain controller 298 | * A regular Windows Server is good enough 299 | * 'Allow Log On As A Batch Job' user right is required when using a scheduled task 300 | * That can be configured as follows: 301 | * Grant-UserRight -Right SeBatchLogonRight -Account "\\\\"\ 302 | (**REMARK**: Part of PowerShell Module: https://gallery.technet.microsoft.com/scriptcenter/Grant-Revoke-Query-user-26e259b0)\ 303 | OR 304 | * NTRIGHTS.EXE +r SeBatchLogonRight -u "\\\\"\ 305 | (**REMARK**: Part of W2K3 Resource Kit Tools: https://www.microsoft.com/en-us/download/details.aspx?id=17657)\ 306 | OR 307 | * Assign it through a GPO Policy (*Computer Configuration -> Policies --> Windows Settings --> Security Settings --> Local Policies --> User Rights Assignment --> Log on as a batch job*) 308 | * A scheduled task to execute the batch which in turn executes the powershell script\ 309 | (**REMARK**: In all cases the default 'Least Privilege' is configured. Try that first to see if it works. However due to UAC when reading password related user properties you may need to reconfigure the scheduled task to use 'Highest Privileges') 310 | * That can be configured as follows: 311 | * Using the template "scheduledTask_Notify Users With Expired Accounts And Or Passwords.xml" to import. Before the import make sure to edit the template: 312 | * Replace 'DOMAIN\AUTHOR_USER' with the corresponding info of the user used to import the scheduled task (*Section: Task\RegistrationInfo\Author*) 313 | * Replace 'DOMAIN\EXEC_USER' with the corresponding info of the user used run the scheduled task on a regular basis (*Section: Task\Principals\Principal\UserId*) 314 | * Replace 'FULL PATH TO AD-Exp-Notify.cmd' with the full path of the batch file 'AD-Exp-Notify.cmd' (*Section: Task\Actions\Exec\Command*) 315 | * Replace 'FULL PATH OF FOLDER OF AD-Exp-Notify.cmd' with the full path of the folder containing the batch file 'AD-Exp-Notify.cmd' (*Section: Task\Actions\Exec\WorkingDirectory*)\ 316 | OR 317 | * Assign it through a GPO Preference (*Computer Configuration -> Preferences --> Control Panel Settings --> Scheduled Tasks --> Local Policies --> User Rights Assignment*)\ 318 | OR 319 | * Using PowerShell to create and configure the scheduled task 320 | ```PowerShell 321 | $scheduledTaskAction = New-ScheduledTaskAction -Execute "" -WorkingDirectory "" 322 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -Weekly -WeeksInterval 1 -DaysOfWeek "" -At "