Import users and groups from Active Directory using a .csv file. The CSV file usually is an export of Active Directory users or groups. Following steps illustrate how administrators
can create valid .csv files and import them to the cloud portal.
Steps
-
To create the .csv files run the following scripts in PowerShell with administrator permissions. Use of PowerShell7 or higher is recommended.
Export Active-Directory users script:
Get-ADUser -Filter * -Properties * | Select -Property GivenName,
sn, title, physicalDeliveryOfficeName, streetAddress, l, st,
postalCode, c, mobile, mail, department, userPrincipalName,
ObjectSid, sAMAccountName, distinguishedName,
@{Name="ManagerEmail";Expression={(get-aduser -property
emailaddress $_.manager).emailaddress}},
@{n="ManagerName";e={get-aduser $_.manager | select -
ExpandProperty name}} | export-csv -path c:\temp\userexport.csv -
NoTypeInformation -Encoding UTF8
Export Active-Directory groups script:
Get-ADGroup -Filter 'GroupCategory -eq "Security"' -Properties *
| Select -Property objectSid, distinguishedName, name |
Export-Csv -Path C:\temp\groupexport.csv -NoTypeInformation -Encoding UTF8
Open the exported files using Notepad++, click on Encoding and ensure that UTF-8 is checked.
-
The resulting user or group file can be imported using or respectively.
Errors during import
If the .csv file contains items with missing mandatory fields, then following error will be displayed. By clicking Download File you can view the list of items
with errors which failed during import.
Error
If the .csv file entries have issues:
- Case 1- All items in file are missing mandatory fields
- Case 2 – File format is not valid
- Case 3 – File encoding is different from utf-8
Mandatory fields: Ensure to include the mandatory fields necessary.
- Users
- - userPrincipalName
- - objectSid
- Groups