Are you trying to uninstall the Azure ad PowerShell module?
This guide will help you.
If you have the Azure ad PowerShell Module installed on your system and would like to uninstall it, there are different options to implement it.
The method you choose to follow depends on how you installed the Azure module in the first place.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform PowerShell related queries .
In this context, we shall look into how to uninstall the Azure ad Powershell module.
Now apply the following methods to uninstall the Azure ad PowerShell module.
If you have installed the Az PowerShell module using the MSI package then you would need to uninstall it through the Windows System.
In Windows 10, you can uninstall it by clicking on Start >> Apps.
In Windows 7,8, you can uninstall it by Clicking on Start >> Control Panel >> Programs >> Uninstall a program.
Once you have reached this screen then you will see the Azure PowerShell in the program listing. You would need to uninstall this app.
In order to uninstall the Az modules, we can use the Uninstall-Module cmdlet. However, the Uninstall-Module will only uninstall a single module. So in order to remove the Az PowerShell module completely then you would need to uninstall all the modules individually.
Run the below command to check the version of the Az PowerShell module:
Get-InstalledModule -Name Az -AllVersions
The below script will uninstall the correct version of each submodule.
However, to run this script you need administrator access:
function Uninstall-AzModule {
[CmdletBinding(SupportsShouldProcess)]
param(
[ValidateNotNullOrEmpty()]
[ValidateSet('Az','AzureRM','Azure')]
[string]$Name = 'Az',
[Parameter(Mandatory)]
[string]$Version,
[switch]$AllowPrerelease
)
$Params = @{}
if ($PSBoundParameters.AllowPrerelease) {
$Params.AllowPrerelease = $true
}
$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')
if (-not(Get-InstalledModule -Name $Name -RequiredVersion $Version -ErrorAction SilentlyContinue -OutVariable RootModule @Params)) {
Write-Warning -Message "Uninstall aborted. $Name version $Version not found."
} elseif (($RootModule.InstalledLocation -notlike "*$env:USERPROFILE*") -and ($IsAdmin -eq $false)) {
Write-Warning -Message "Uninstall aborted. $Name version $Version exists in a system path. PowerShell must be run elevated as an admin to remove it."
} elseif ((Get-Process -Name powershell, pwsh -OutVariable Sessions -ErrorAction SilentlyContinue).Count -gt 1) {
Write-Warning -Message "Uninstall aborted. Please close all other PowerShell sessions before continuing. There are currently $($Sessions.Count) PowerShell sessions running."
} else {
Write-Verbose -Message 'Creating list of dependencies...'
$target = Find-Module -Name $Name -RequiredVersion $Version @Params
$AllModules = @([pscustomobject]@{
Name = $Name
Version = $Version
})
$AllModules += foreach ($dependency in $target.Dependencies) {
switch ($dependency.keys) {
{$_ -contains 'RequiredVersion'} {$UninstallVersion = $dependency.RequiredVersion; break}
{$_ -contains 'MinimumVersion'} {$UninstallVersion = $dependency.MinimumVersion; break}
}
[pscustomobject]@{
Name = $dependency.Name
Version = $UninstallVersion
}
}
[int]$i = 100 / $AllModules.Count
foreach ($module in $AllModules) {
Write-Progress -Activity 'Uninstallation in Progress' -Status "$i% Complete:" -PercentComplete $i
$i++
if (Get-InstalledModule -Name $module.Name -RequiredVersion $module.Version -ErrorAction SilentlyContinue @Params) {
Write-Verbose -Message "Uninstalling $($module.Name) version $($module.Version)"
Remove-Module -FullyQualifiedName @{ModuleName=$module.Name;ModuleVersion=$module.Version} -ErrorAction SilentlyContinue
try {
if ($PSCmdlet.ShouldProcess("$($module.Name) version $($module.Version)")) {
Uninstall-Module -Name $module.Name -RequiredVersion $module.Version -Force -ErrorAction Stop @Params
}
$State = 'Uninstalled'
} Catch {
$State = 'Manual uninstall required'
Write-Verbose -Message "$($module.Name) version: $($module.Version) may require manual uninstallation."
}
} else {
$State = 'Not found'
Write-Verbose -Message "$($module.Name) version: $($module.Version) not found."
}
if (-not $PSBoundParameters.WhatIf) {
[pscustomobject]@{
ModuleName = $module.Name
Version = $module.Version
State = $State
}
}
}
}
}
Then, Copy and paste the above script in your PowerShell session.
The below example shows to remove an older version of the Az PowerShell module and its submodules:
Uninstall-AzModule -Name Az -Version 1.8.0
As the script runs, it displays the Name, Version, and State of each submodule that is being uninstalled.
In case, if you have installed the Az module on your system and want to uninstall the AzureRM, then there are two ways to uninstall it.
It completely depends on how you have installed it.
You can follow this method if you have installed the AzureRM PowerShell module using the MSI package. Here you would need to uninstall it through the Windows system.
In Windows 10, you can uninstall it by clicking on Start >> Settings >> Apps.
In Windows 7,8, you can uninstall it by Clicking on Start >> Control Panel >> Programs >> Uninstall a program.
Once you have reached this screen then you will see the Azure PowerShell or Microsoft Azure PowerShell – Month Year in the program listing.
You would need to uninstall this app.
You can follow this method if you have installed the AzureRM PowerShell module using the PowerShellGet.
You can use the Uninstall-AzureRM cmdlet for uninstalling purposes.
Run the below command to remove all AzureRM modules from your machine.
However, to run it you need to have the administrator privileges:
Uninstall-AzureRm
This article covers how to uninstall the #Azure #PowerShell module and AzureRM module from MSI and PowerShellGet.
To uninstall all official PowerCLI modules except VMware.PowerCLI, run the following command:
(Get-Module VMware.PowerCLI -ListAvailable).RequiredModules | Uninstall-Module -Force
When you want to uninstall the program, you can go to the Programs and Features to uninstall it.
So when you want to uninstall Windows Azure SDK and Windows Azure Tools for Microsoft Visual Studio (the first solution is to uninstall it via Programs and Features.
How do I uninstall Windows PowerShell?
Uninstall PowerShell from Start Menu.
1. You can click Start menu at the bottom-left, type PowerShell in the search box, and you will see Windows PowerShell app.
2. Right-click Windows PowerShell app, and select Uninstall, or expand the menu in the right to select Uninstall to remove Windows PowerShell exe from Windows 10.
To Install VMware PowerCLI Module From PC With Internet Connection:
1. From a computer with an internet connection open powershell (preferrably as an administrator)
2. Find-Module -Name VMware.PowerCLI.
3. Install-Module -Name VMware.PowerCLI -Scope CurrentUser.
4. Get-Command -Module *VMWare*
To use Azure PowerShell in PowerShell 5.1 on Windows:
1. Update to Windows PowerShell 5.1. If you're on Windows 10 version 1607 or higher, you already have PowerShell 5.1 installed.
2. Install . NET Framework 4.7.
3. Make sure you have the latest version of PowerShellGet. Run Install-Module -Name PowerShellGet -Force .