Framework/Core/MetadataInfo/EnvironmentInfo.ps1

using namespace System.Management.Automation
Set-StrictMode -Version Latest 

class EnvironmentInfo: CommandBase
{    

    EnvironmentInfo([string] $subscriptionId, [InvocationInfo] $invocationContext): 
        Base($subscriptionId, $invocationContext) 
    { 
    }
    
    GetEnvironmentInfo()
    {
        $this.PublishCustomMessage([Constants]::DoubleDashLine + "`r`nEnvironment Details `r`n" + [Constants]::DoubleDashLine);

        $loadedModules = (Get-Module | Select-Object -Property Name, Description, Version, Path);
        $this.PublishCustomMessage("Loaded PowerShell modules", [MessageType]::Default);
        $this.PublishCustomMessage([Helpers]::ConvertObjectToString($loadedModules, $true), [MessageType]::Default);
        $this.PublishCustomMessage([Constants]::SingleDashLine);

        $rmContext = Get-AzureRmContext;

        $this.PublishCustomMessage("Logged-in user context", [MessageType]::Default);
        $this.PublishCustomMessage([Helpers]::ConvertObjectToString(($rmContext.Account | Select-Object -Property Id, Type), $true), [MessageType]::Default);
        $this.PublishCustomMessage([Constants]::SingleDashLine);

        $this.PublishCustomMessage("AzureRM context", [MessageType]::Default);
        $this.PublishCustomMessage([Helpers]::ConvertObjectToString(($rmContext | Select-Object -Property Environment, Subscription, Tenant), $false), [MessageType]::Default);
        $this.PublishCustomMessage([Constants]::SingleDashLine);
    }
}