Share via

Powershell Administration for Password Based SSO on Enterprise Apps

SCHÖRGHOFER Harald 111 Reputation points
2021-04-16T10:14:53.377+00:00

I would like to perform account onboarding for a Password based SSO Enterprise Application. The goal should be to add a few hundred users to an existing application or to update existing credentials.
But when I load the module (Install-Module -Name Microsoft.Graph.Applications) and import it, when I try to execute the CMDLet
New-MgServicePrincipalPasswordSingleSignOnCredentials I get the error: The term 'New-MgServicePrincipalPasswordSingleSignOnCredentials' is not recognized as the name of a cmtlet....

Does anyone know why I get this error?
Also, does anyone have sample code to add and update such credentials?

Thanks a lot
Harald

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph

Answer accepted by question author

SCHÖRGHOFER Harald 111 Reputation points
2021-04-19T15:24:48.467+00:00

in the meantime i figured out how to do it:
Here is the solution if others require it.

Assign the values to the variables

$username = "Testuser@test .com"
$app_name = "MyTest1"
$app_role_name = "User"

Get the user to assign, and the service principal for the app to assign to

$user = Get-AzureADUser -ObjectId "$username"
$sp = Get-AzureADServicePrincipal -Filter "displayName eq '$app_name'"
$appRole = $sp.AppRoles | Where-Object { $_.DisplayName -eq $app_role_name }

Assign the user to the app role

New-AzureADUserAppRoleAssignment -ObjectId $user.ObjectId -PrincipalId $user.ObjectId -ResourceId $sp.ObjectId -Id $appRole.Id

https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/assign-user-or-group-access-portal

Assign Password Based SSO Credentials

$credentials = New-Object -TypeName Microsoft.Open.MSGraph.Model.PasswordSSOCredentials
$credentials.Id = "xx0a75bd-yy60-xx8e-xx61-7fcxxyy70886"
$creds1 = [Microsoft.Open.MSGraph.Model.PasswordSSOCredential]@{FieldId="param_1"; Value="user@test .com"; Type="text"}
$creds2 = [Microsoft.Open.MSGraph.Model.PasswordSSOCredential]@{FieldId="param_2"; Value="BlaBlaPassword"; Type="password"}
$credentials.Credentials = @($creds1, $creds2)

$new_creds_output = New-AzureADMSPasswordSingleSignOnCredential -ObjectId xxb42c1e-bfxx-4bxx-b72a-xx16af9f75ba -PasswordSSOCredential $credentials

https://learn.microsoft.com/en-us/powershell/module/azuread/set-azureadmspasswordsinglesignoncredential?view=azureadps-2.0-preview

KR Harald

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.