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

Include Environment used with Connect-MgGraph in the Get-MgContext output

Open JefTek opened this issue 4 years ago • 1 comments

When using the Connect-MgGraph -Environment, include the environment used on the output of Get-mgContext.

This can be used to identify the needed GraphEndpoints from Get-MgEnvironment dynamically based on connection context when issuing queries with Invoke-MgGraphRequest that don't support a relative URI.

IE $GraphEndpoint = (Get-MgEnvironment -Name ((Get-MgContext).Environment)).GraphEndpoint Invoke-MgGraphRequest -Method Get -URI "$GraphEndpoint/beta/me"

JefTek avatar Sep 28 '21 23:09 JefTek

Hi @JefTek, we can include the configured environment to the output of Get-MgContext.

Invoke-MgGraphRequest is environment aware and should automatically change the host URL based on the configured environment when a relative URI is used. @georgend, why don't we support relative URI when using HTTP methods other than GET?

peombwa avatar Sep 29 '21 16:09 peombwa