Skip to content

Commit

Permalink
Replace Get-InstalledModule with Get-Module -ListAvailable
Browse files Browse the repository at this point in the history
  • Loading branch information
msJinLei committed Jan 12, 2023
1 parent c5b7bf0 commit 680bf76
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/Az.Tools.Installer/Az.Tools.Installer.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class ModuleInfo
function Remove-AzureRM {
process {
try {
$azureModuleNames = (Get-InstalledModule -Name Azure* -ErrorAction Stop).Name | Where-Object {$_ -match "Azure(\.[a-zA-Z0-9]+)?" -or $_ -match "AzureRM(\.[a-zA-Z0-9]+)?"}
$azureModuleNames = (Microsoft.PowerShell.Core\Get-Module -ListAvailable -Name Azure* -ErrorAction Stop).Name | Where-Object {$_ -match "Azure(\.[a-zA-Z0-9]+)?" -or $_ -match "AzureRM(\.[a-zA-Z0-9]+)?"}
foreach ($moduleName in $azureModuleNames) {
PowerShellGet\Uninstall-Module -Name $moduleName -AllVersion -AllowPrerelease -ErrorAction Continue
}
Expand Down

0 comments on commit 680bf76

Please sign in to comment.