Skip to content

Remove-MgmtGraphEnvironment

MgmtGraph: Unregisters a custom Microsoft Graph cloud environment

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

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

Process {
    try {
        $params = @{
            'Name'        = $Name
            'Confirm'     = $false
            'ErrorAction' = 'Stop'
        }

        Remove-MgEnvironment @params
        
        $result = [PSCustomObject]@{
            Name      = $Name
            Action    = "EnvironmentUnregistered"
            Status    = "Success"
            Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        }

        Write-Output $result
    }
    catch {
        throw
    }
}

Specifies the name of the environment to unregister.

An interactive directory of PowerShell scripts.