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 = "AzSKAzureServicesSecurityStatus";
            ShortName = "GRS";
        },
        [CommandDetails]@{
            Verb = "Get";
            Noun = "AzSKControlsStatus";
            ShortName = "GCS";
        },
        [CommandDetails]@{
            Verb = "Get";
            Noun = "AzSKExpressRouteNetworkSecurityStatus";
            ShortName = "GES";
        },
        
        #Subscription Security
        [CommandDetails]@{
            Verb = "Get";
            Noun = "AzSKSubscriptionSecurityStatus";
            ShortName = "GSS";
        },
        [CommandDetails]@{
            Verb = "Set";
            Noun = "AzSKSubscriptionSecurity";
            ShortName = "SSS";
        },
        [CommandDetails]@{
            Verb = "Update";
            Noun = "AzSKSubscriptionSecurity";
            ShortName = "USS";
        },
        [CommandDetails]@{
            Verb = "Remove";
            Noun = "AzSKSubscriptionSecurity";
            ShortName = "RSS";
        },

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

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

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

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

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

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

        # FixControl
        [CommandDetails]@{
            Verb = "Repair";
            Noun = "AzSKAzureServicesSecurity";
            ShortName = "RRS";
        },
        [CommandDetails]@{
            Verb = "Repair";
            Noun = "AzSKSubscriptionSecurity";
            ShortName = "RSS";
        },

        # Policy Store
        [CommandDetails]@{
            Verb = "Install";
            Noun = "AzSKOrganizationPolicy";
            ShortName = "IOP";
        },
        [CommandDetails]@{
            Verb = "Get";
            Noun = "AzSKInfo";
            ShortName = "GAI";
        },
        [CommandDetails]@{
            Verb = "Send";
            Noun = "AzSKInternalData";
            ShortName = "INV";
        }
    );

    static BeginCommand([InvocationInfo] $invocationContext)
    {
        # Validate Command Prerequisites like AzureRM multiple version load issue
        [CommandHelper]::CheckCommandPrerequisites($invocationContext);
        [CommandHelper]::SetAzSDKModuleName($invocationContext);
        # display warning if alias
        [CommandHelper]::CheckForAlias($invocationContext.InvocationName)
    }

    static CheckCommandPrerequisites([InvocationInfo] $invocationContext)
    {
        # Validate required module version dependency
        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 dependency validation successful")
                }            
            };            
        }
        catch
        {
            Write-Debug "Not able to validate version dependency $_"
        }
    }

    static [void] SetAzSDKModuleName([InvocationInfo] $invocationContext)
    {
        if($invocationContext)
        {
            [Constants]::SetAzSDKModuleName($invocationContext.MyCommand.Module.Name);
        }
    }

    static [void] CheckForAlias([string] $methodName)
    {
        if($methodName -like "*-$([Constants]::OldModuleName)*")
        {
            $newMethodName = $methodName -replace ("-"+[Constants]::OldModuleName),("-"+[Constants]::NewModuleName);
            $CommandNameChangeWarning = [Constants]::CommandNameChangeWarning -f $methodName,$newMethodName
            Write-Warning $CommandNameChangeWarning
        }
    }
}