Uninstall Az Powershell Module forcefully and completely

I’m primarily using PowerShell to address Azure automation activities from running from local to Azure itself. The most painful task encountered is about upgrading PowerShell Az modules and making it work with VsCode.

After many trial and error, this is the best method I could recommend to uninstall the PowerShell Az module.

Get-installedmodule Az.*| foreach-object{Uninstall-Module -Name $_.Name -Verbose -AllVersions -force}

If you encounter running the above code snippet from the no-Admin account, switch to the Admin account. Incase Az.Accounts module is adamant in getting uninstalled, open a cmd - As Administrator and run below command. This will rid your system of Az modules.

powershell -NoProfile -NonInteractive -Command "Uninstall-Module Az.Accounts"

Few things learned the hard way when using Powershell extension with VSCode.

if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable))
{
  Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +'Az modules installed at the same time is not supported.')
} else{
    Install-Module -Name Az -AllowClobber -Scope CurrentUser
}