UpdateImmutableID: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
Step 1 - extract users as a list from SQL | Step 1 - extract users as a list from SQL | ||
select distinct STUDIENR from students | |||
where recordtype = 'employee' | |||
and action = 'add' | |||
To update one or more userser | To update one or more userser | ||
Revision as of 12:50, 24 June 2019
This article describes how to extract immutable ID on users from a local AD / OnPremise AD and how to link this to Office 365. This is usefull when using AADC and users cannot be edited directly in the cloud.
Step 1 - extract users as a list from SQL
select distinct STUDIENR from students where recordtype = 'employee' and action = 'add'
To update one or more userser
$usersTable = New-Object system.Data.DataTable “UsersTable”
$column1 = New-Object System.Data.DataColumn userPrincipalName,
([String])
$column2 = New-Object System.Data.DataColumn immutableId,
([String])
$usersTable.Columns.Add($column1)
$usersTable.Columns.Add($column2)
$users=Import-Csv -Path users.csv -Header “userSamAccountName”
foreach($user in $users)
{
$adUser = Get-ADUser -Identity $user.userSamAccountName
$adUserGuid = $adUser.ObjectGUID
$byteArray = $adUserGuid.ToByteArray()
$immutableId = “”
$immutableId = [system.convert]::ToBase64String($byteArray)
$row = $usersTable.NewRow()
$row.userPrincipalName = $adUser.userPrincipalName
$row.immutableId = $immutableId
$usersTable.Rows.Add($row)
}
$usersTable | Export-Csv “c:\Users\Inlogic\UserExportIds.csv”