- This script uses the Microsoft Graph API and requires an App Registration with App permissions:
- Read all users' full profiles User.Read.All
This code snippet executes the following tasks:
- Define
$givenName
based on thegivenName
data source input$dataSource.givenName
- Define
$middleName
based on themiddleName
data source input$dataSource.middleName
- Define
$lastName
based on thelastName
data source input$dataSource.lastName
- Define
$UPNsuffix
based on theemployeeType
data source input$dataSource.employeeType.UPNsuffix
- Creates a token to connect to the Graph API.
- Generate
surname
. - Generate
displayname
. - Generate
userPrincipalName
and check if this is unique in Azure AD (using the API call: Get a user), otherwise continue with next iteration. - Set
mail
equal touserPrincipalName
. - Return a hash table for each user account using the
Write-Output
cmdlet.
To view an example of the data source output, please refer to the JSON code pasted below and select the
Interpreted as JSON
option in HelloID
{
"givenName": "Janine",
"middleName": "van den",
"lastName": "Boele",
"employeeType": {
"Name": "Employee",
"UPNsuffix": "devbreekie18.onmicrosoft.com",
"Type": "Member",
"Organization": "T4EJB"
}
}