Purpose
Quickpass by CyberQP leverages the 'mail' Active Directory attribute from an End User AD Object to populate the Quickpass account's email field at time of import. To assist in completing a bulk update of the 'mail' Active Directory attribute for your domain End Users before the Quickpass automatic import is done, the following Powershell scripts have been developed.
Application
Script #1 - Start Here
Attached at the bottom of this article or here - exportUsersFromOU.ps1
This script will get User accounts from the desired OU and any SubOU and export that information to a CSV locally. The CSV will contain for each User account the UPN, Display Name, Email, and Organizational Unit.
NOTE: As this is a custom built script, you may have to enable the permission to run the script by using the command:
Set-ExecutionPolicy Bypass
When running the script from command line you will be prompted to enter the fully formatted Distinguished name of the target OU, allowing you to be as granular or broad as you need for your User export.
#e.g., OU=subOU,OU=rootOU,DC=domain,DC=com
OR
#e.g., DC=domain,DC=com
The CSV file will create and export to the following location unless changed in the script - C:\User Object Export\ouExport.csv
- NOTE: If the export location is changed in the script, you will also need to change the variable '$csvPath' in Script #2 accordingly.
Once the file is exported, open the CSV and populate the 'mail' column for the User account(s) as desired.
Once completed, proceed to Script #2.
- NOTE: If you want to manually populate the CSV and use that as the target file for Script #2 - updateMailFromCSV.ps1, a template CSV, ouExport.csv, has been attached to the bottom of this article.
Script #2
Attached at the bottom of this article or here - updateMailFromCSV.ps1
This script will scan through the CSV and update the E-mail address as populated in the CSV for each User account referenced.
By default, only User accounts that have the Mail attribute empty will be updated. If you desire to update all User accounts referenced in the CSV regardless of the current value in the User(s) Mail attribute, append the '-ForceUpdate' parameter when running the script from command line.
NOTE: As this is a custom built script, you may have to enable the permission to run the script by using the command:
Set-ExecutionPolicy Bypass
Example executions of the script:
PS cd C:\>.\updateMailFromCSV.ps1
PS C:\>.\updateMailFromCSV.ps1 -ForceUpdate
For a User account that was successful updated, the following message will display:
Updated E-mail for user $displayName in Domain: $domain
Otherwise, if '-ForceUpdate' was not enabled, the following message will display for all User accounts that did not meet the criteria for update:
E-mail for $displayName is already populated. No update was made.
Comments
0 comments
Article is closed for comments.