Loading Staff from Active Directory – AD PowerShell script

Loading Staff from Active Directory – AD PowerShell script

Active Directory and LDAP can be leveraged to enable automated importation of a staff list into VisitorRego.

Active Directory integration is intended for a system administrator or IT specialist to set up. Knowledge of how your Active Directory is structured to pull the correct information is required. Please contact your system administrator for assistance in setting up this feature.

If your VisitorRego unit is connected to your network, please see here for information on AD integration through the software itself.

If your VisitorRego unit is not connected to your network, a PowerShell script can be generated for your site to batch load staff from your Active Directory which can then be scheduled as a background  task. The following details provide guidance on how to use the script.

AD PowerShell script Information


The script is run on a machine or server that is domain connected (so it can read AD) and retrieves Active Directory user information for specified queries and sends the data to the VisitorRego remote API.
The VisitorRego unit synchronises with the server to refresh the locally held staff list.

To use the AD PowerShell script, the machine or server you are running the script from will need to be able to communicate with both your Active Directory, and the VisitorRego remote API https://adupdate.visitorrego.com/.
The VisitorRego unit itself would also need to be able to communicate with the VisitorRego server.

To obtain the AD PowerShell script, contact the VisitorRego support team. The support team will generate the script and provide it to you. The script includes site specific variables which allow the data to be sent to your site correctly.

Modifying the script


Once you have received your site specific generated script, the file can be edited with notepad.
You will find a synopsis and notes at the top of the script which briefly summarises what the script does, and what can and can't be modified.

There are sections within the script that are commented with DO NOT MODIFY. These sections are to not be modified.

To enter your AD domain details and LDAP search filter, scroll down to the 'Define site information here' section.
Enter your AD server details, search base and LDAP search filter into their respective areas.


Server - An AD server, or domain controller, hosts and manages Active Directory services. It stores user accounts, groups, computer objects, and other resources in a network domain.
Searchbase - A distinguished name (DN) or path that specifies where to search and retrieve objects or information. Specifying the search base in AD queries helps narrow the scope to specific organizational units, containers, or domains.
Searchfilter - The criteria used to specify parameters for an Active Directory search, defining specific requirements for retrieving objects. It uses LDAP syntax, including attributes and logical operators, to create complex search conditions and narrow down results to the desired objects.

Once you have entered the details, save the file.

Testing the script


Once you are ready to test, you will find a section within the script; "UNCOMMENT FOR PRODUCTION".
Make sure the line "$production = $true" has been commented out and "$production = $false" has been uncommented.



If set to false, running the script will display the AD user information in a grid view and not send data.

When the script has been run, it will check for the required Active Directory module for PowerShell. If the module is missing, the script will download it.

Using the script in production


Once you have tested the script and have checked the grid view output is correct, uncomment the line "$production = $true".
You can then run the script with PowerShell and the list of users will be loaded into your VR Portal site.

Automating the script using Task Scheduler


Once you are able to load staff successfully using the script, you can automate the process as a background task using Windows Task Scheduler. Follow the steps below to do this:

  1. Open Windows Task Scheduler.
  2. Click the Action menu, then click Create Basic Task.
  3. In the Name field, type a short descriptive name for the task. For example, ADUpdate.
  4. Click the Next button.
  5. Select the frequency on when you want the task to start.
  6. Click the Next button.
  7. Using the Start settings, specify when the task should start running and the time.
  8. Click the Next button.
  9. Select the Start a program option to launch an app, run a command, or execute a script file.
  10. In the "Program/script" field, specify the path of the script.
  11. Click the Finish button.

 

Once you've completed the steps, the task will be saved, and it'll run automatically on the schedule you specified.


    • Related Articles

    • Loading Staff from Active Directory – Domain Connected

      Active Directory and LDAP can be leveraged to enable automated importation of a staff list into VisitorRego. Active Directory integration is intended for a system administrator or IT specialist to set up. Knowledge of how your Active Directory is ...
    • An Overview of Loading Staff from Active Directory

      Active Directory and LDAP can be leveraged to enable automated importation of a staff list into VisitorRego. Active Directory integration is intended for a system administrator or IT specialist to set up. Knowledge of how your Active Directory is ...
    • Loading Staff from Active Directory - AD Quick Load

      As many companies have a large number of staff, loading them individually is an impractical task. To mitigate this, VisitorRego can pull the staff list from an Active Directory to populate the staff list. The instructions in this article guide you to ...
    • An Overview of Loading Staff

      When a person signs in, they specify the staff member they are meeting with. Following registration, notifications can be sent to the designated staff member via email, text message (SMS), or a combination of both, informing the staff member that the ...
    • Active Directory integration

      Streamline staff list management effortlessly with Active Directory integration for VisitorRego. This feature simplifies staff data importation by leveraging a PowerShell script for off-network VisitorRego units. When your VisitorRego unit is ...