Framework/Helpers/CommandHelper.ps1

using namespace System.Management.Automation
Set-StrictMode -Version Latest  
class CommandHelper
{
    static [CommandDetails[]] $Mapping = @(
        # Services Security Status
        [CommandDetails]@{
            Verb = "Get";
            Noun = "AzSDKAzureServicesSecurityStatus";
            ShortName = "GRS";
        },
        [CommandDetails]@{
            Verb = "Get";
            Noun = "AzSDKControlsStatus";
            ShortName = "GCS";
        },
        [CommandDetails]@{
            Verb = "Get";
            Noun = "AzSDKExpressRouteNetworkSecurityStatus";
            ShortName = "GES";
        },
        
        #Subscription Security
        [CommandDetails]@{
            Verb = "Get";
            Noun = "AzSDKSubscriptionSecurityStatus";
            ShortName = "GSS";
        },
        [CommandDetails]@{
            Verb = "Set";
            Noun = "AzSDKSubscriptionSecurity";
            ShortName = "SSS";
        },
        [CommandDetails]@{
            Verb = "Remove";
            Noun = "AzSDKSubscriptionSecurity";
            ShortName = "RSS";
        },

        # CA
        [CommandDetails]@{
            Verb = "Get";
            Noun = "AzSDKContinuousAssurance";
            ShortName = "GCA";
        },
        [CommandDetails]@{
            Verb = "Install";
            Noun = "AzSDKContinuousAssurance";
            ShortName = "ICA";
        },
        [CommandDetails]@{
            Verb = "Remove";
            Noun = "AzSDKContinuousAssurance";
            ShortName = "RCA";
        },
        [CommandDetails]@{
            Verb = "Update";
            Noun = "AzSDKContinuousAssurance";
            ShortName = "UCA";
        },

        #Alerts
        [CommandDetails]@{
            Verb = "Set";
            Noun = "AzSDKAlerts";
            ShortName = "SAL";
        },
        [CommandDetails]@{
            Verb = "Remove";
            Noun = "AzSDKAlerts";
            ShortName = "RAL";
        },

        #ARM Policies
        [CommandDetails]@{
            Verb = "Set";
            Noun = "AzSDKARMPolicies";
            ShortName = "SAP";
        },
        [CommandDetails]@{
            Verb = "Remove";
            Noun = "AzSDKARMPolicies";
            ShortName = "RAP";
        },

        #RBAC
        [CommandDetails]@{
            Verb = "Set";
            Noun = "AzSDKSubscriptionRBAC";
            ShortName = "SRB";
        },
        [CommandDetails]@{
            Verb = "Remove";
            Noun = "AzSDKSubscriptionRBAC";
            ShortName = "RRB";
        },

        # Security Centre
        [CommandDetails]@{
            Verb = "Set";
            Noun = "AzSDKAzureSecurityCenterPolicies";
            ShortName = "SSC";
        },

        # OMS
        [CommandDetails]@{
            Verb = "Install";
            Noun = "AzSDKOMSSolution";
            ShortName = "IOM";
        },
        [CommandDetails]@{
            Verb = "Uninstall";
            Noun = "AzSDKOMSetup";
            ShortName = "UOM";
        },

        # FixControl
        [CommandDetails]@{
            Verb = "Repair";
            Noun = "AzSDKAzureServicesSecurity";
            ShortName = "RRS";
        },
        [CommandDetails]@{
            Verb = "Repair";
            Noun = "AzSDKSubscriptionSecurity";
            ShortName = "RSS";
        }
    );

    static BeginCommand([InvocationInfo] $invocationContext)
    {
        # 1. Validate Command Prerequisites like AzureRM multiple version load issue
        [CommandHelper]::CheckCommandPrerequisites($invocationContext);
    }

    static CheckCommandPrerequisites([InvocationInfo] $invocationContext)
    {
        # Validate required module version dependancy
        try
        {            
            #Loop through all required modules list
            $invocationContext.MyCommand.Module.RequiredModules | ForEach-Object {                
                $requiredModule = $_
                $moduleList = Get-Module $requiredModule.Name 
                #Get list of other than required version is loaded into session
                $otherThanRequiredModule = @();
                $otherThanRequiredModule += $moduleList | Where-Object { $_.Version -ne $requiredModule.Version}
                if($otherThanRequiredModule.Count -gt 0 )
                {     
                    #Display warning
                    $loadedVersions = @();
                    $moduleList | ForEach-Object {
                        $loadedVersions += $_.Version.ToString()
                    };
                    Write-Host "Warning: Found multiple versions of Azure PowerShell ($($requiredModule.Name)) modules loaded in the session. ($($requiredModule.Name) versions found: $([string]::Join(", ", $loadedVersions)))" -ForegroundColor Yellow
                    Write-Host "Warning: This will lead to issues when running AzSDK cmdlets." -ForegroundColor Yellow
                    Write-Host 'Recommendation: Please start a fresh PowerShell session and run “import-module AzSDK” first to avoid getting into this situation.' -ForegroundColor Yellow                    
                }
                else
                {
                    # Continue execution without any error or warning
                    Write-Debug ($requiredModule.Name + " module version dependancy validation successful")
                }            
            };            
        }
        catch
        {
            Write-Debug "Not able to validate version dependancy $_"
        }
    }
}