Companion Code Advanced User Import - TheJumpCloud/support GitHub Wiki

Companion Code - Advanced User Import

Prerequisites

Creating a JumpCloud User group for each unique department value in Active Directory


PS > Get-ADUser -Filter {department -ne "$null"} -Properties * | Select-Object department -Unique | ForEach-Object {New-JCUserGroup -GroupName $_.Department}

Creates a new JumpCloud User Group for each unique department value populated within the user 'department' field for all users within the Active Directory domain.

Exporting Users from specific OU's to a .CSV file with the correct JumpCloud import column headers


PS > Get-ADUser -Filter * -Properties * `
-SearchBase "OU=DenverOffice,OU=Employees,DC=Azzipa01,DC=local" | `
Select-Object @{name = 'FirstName'; expression = {$_.givenname}}, `
 @{name = 'LastName'; expression = { $_.surname}}, `
 @{name = 'UserName'; expression = {$_.samaccountname}}, `
 @{name = 'Email'; expression = { $_.mail }}, `
 @{name = 'StartDate'; expression = {$_.created}}, `
 @{name = 'Department'; expression = {$_.department}} | `
 Export-Csv 'DenverUserExport.CSV'

In this example users live the DenverOffice OU and the domain is 'Azzipa01.local".

This is a single line command that is spread across multiple lines using the PowerShell escape character the backtick " ` " for increased readability.

All users within the searchbase ""OU=DenverOffice,OU=Employees,DC=Azzipa01,DC=local"" are exported to the CSV file "DenverUserExport.csv".


PS >  Get-ADUser -Filter * -Properties * `
-SearchBase "OU=BoulderOffice,OU=Employees,DC=Azzipa01,DC=local" | `
Select-Object @{name = 'FirstName'; expression = {$_.givenname}}, `
 @{name = 'LastName'; expression = { $_.surname}}, `
 @{name = 'UserName'; expression = {$_.samaccountname}}, `
 @{name = 'Email'; expression = { $_.mail }}, `
 @{name = 'Department'; expression = {$_.department}}, `
 @{name = 'StartDate'; expression = {$_.created}} | `
 Export-Csv 'BoulderUserExport.CSV'

In this example users live the BoulderOffice OU and the domain is 'Azzipa01.local".

This is a single line command that is spread across multiple lines using the PowerShell escape character the backtick " ` " for increased readability.

All users within the searchbase ""OU=BoulderOffice,OU=Employees,DC=Azzipa01,DC=local"" are exported to the CSV file "BoulderUserExport.csv".

Modifying this command for your domain

Both the '-Filter' and '-SearchBase' fields can be used to determine which users you wish to export to a CSV file.

If you wish to export all active users within Active Directory and do not wish to export users from a specific OU use this command:


PS > Get-ADUser -Filter 'enabled -eq $true' -Properties * | `
Select-Object @{name = 'FirstName'; expression = {$_.givenname}}, `
 @{name = 'LastName'; expression = { $_.surname}}, `
 @{name = 'UserName'; expression = {$_.samaccountname}}, `
 @{name = 'Email'; expression = { $_.mail }}, `
 @{name = 'Department'; expression = {$_.department}}, `
 @{name = 'StartDate'; expression = {$_.created}} | `
 Export-Csv 'AllEnabledUsers.CSV'

Please reference this link for additional documentation and examples for the Get-ADUser command.

Examples that show how to set the 'searchbase' for Get-ADUser can be found at the bottom of the linked page above.

After exporting your users to a CSV file it is always best practice to groom the data in this .CSV and clean up any stale or incorrect information before importing new users into JumpCloud.