Skip to content

Add-MgmtGraphEnvironment

MgmtGraph: Registers a custom Microsoft Graph cloud environment

#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Authentication

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true)]
    [string]$Name,

    [Parameter(Mandatory = $true)]
    [string]$AzureADEndpoint,

    [Parameter(Mandatory = $true)]
    [string]$GraphEndpoint
)

Process {
    try {
        $params = @{
            'Name'            = $Name
            'AzureADEndpoint' = $AzureADEndpoint
            'GraphEndpoint'   = $GraphEndpoint
            'ErrorAction'     = 'Stop'
        }

        $env = Add-MgEnvironment @params
        
        $result = [PSCustomObject]@{
            Name            = $env.Name
            AzureADEndpoint = $env.AzureADEndpoint
            GraphEndpoint   = $env.GraphEndpoint
            Status          = "EnvironmentRegistered"
            Timestamp       = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        }

        Write-Output $result
    }
    catch {
        throw
    }
}

Specifies the name of the environment to register.

Specifies the Azure AD endpoint URL for the environment.

Specifies the Microsoft Graph endpoint URL for the environment.

An interactive directory of PowerShell scripts.