msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Update authentication with Graph SDK

Open worldsdream opened this issue 2 years ago • 5 comments

Is your feature request related to a problem? Please describe. We can’t set authentication methods with Graph SDK. We have to use entra admin center or https://learn.microsoft.com/en-us/graph/api/authentication-update?view=graph-rest-beta&tabs=http

Describe the solution you'd like A feature to get the option for setting the authentication methods with Microsoft Graph PowerShell SDK.

Describe alternatives you've considered We can use: https://learn.microsoft.com/en-us/graph/api/authentication-update?view=graph-rest-beta&tabs=http

worldsdream avatar Dec 09 '23 14:12 worldsdream

This is very easy to do using the all purpose Invoke-mgGraphRequest cmdlet. Just figure out what values you want to set and put them in the body hashtable. Leave out ones you don't want to modify.

invoke-mgGraphRequest -Uri 'https://graph.microsoft.com/beta/users/[UPN OR ID]/authentication/signInPreferences' -Method PATCH -Body @{systemPreferredMethodForSecondaryAuthentication = "push"; isSystemPreferredAuthenticationMethodEnabled= "false"; userPreferredMethodForSecondaryAuthentication= "push"}

ioamnesia avatar Dec 13 '23 21:12 ioamnesia

Hi @worldsdream have you tried using Invoke-MgGraphRequest as per @ioamnesia's suggestion?

timayabi2020 avatar Dec 15 '23 15:12 timayabi2020

@timayabi2020 It works with Invoke-RestMethod.

But isn’t the graph sdk so we can interact with Graph using PowerShell?

worldsdream avatar Dec 15 '23 16:12 worldsdream

@timayabi2020 It works with Invoke-RestMethod.

But isn’t the graph sdk so we can interact with Graph using PowerShell? Invoke-MgGraphRequest is a commandlet within the Microsoft Graph PowerShell SDK. See documentation here

timayabi2020 avatar Dec 15 '23 16:12 timayabi2020

I thought that we will get an option. For example with “Get-“.

worldsdream avatar Dec 19 '23 19:12 worldsdream