Skip to content

Commit b55f61b

Browse files
authored
Merge pull request #206 from Azure/users/jerskine/updateazaccounts
Update uninstall commands for Az.Accounts
2 parents be18f97 + 9d6238c commit b55f61b

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

TSG/EnvironmentValidator/Troubleshooting-MSI-Does-Not-Have-Access-To-Subscription.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,24 @@ There are two possible issues that can cause this:
5656
2) Role Assignment for Azure Stack HCI Device Management Role is not correct.
5757

5858
## If any other version of Az.Accounts apart from 4.0.2 is installed on the nodes follow the below steps:
59-
***
60-
1. Uninstall all the versions of az.accounts on all nodes
59+
6160
```
62-
Uninstall-Module az.accounts -allversions
61+
$RequiredModuleName = 'Az.Accounts'
62+
$RequiredModuleVersion = '4.0.2'
63+
64+
# Get all versions of the module
65+
Get-InstalledModule -Name $RequiredModuleName -AllVersions
66+
67+
# Uninstall all but the required version.
68+
Get-InstalledModule -Name $RequiredModuleName -AllVersions | Where-Object { $_.Version -ne $RequiredModuleVersion } | ForEach-Object { Uninstall-Module -Name $RequiredModuleName -RequiredVersion $_.Version -Force }
69+
70+
# If the required version was not present in the first command's output, install it.
71+
Install-Module -Name $RequiredModuleName -RequiredVersion $RequiredModuleVersion -Force
72+
73+
# Verify only the required version is installed
74+
Get-InstalledModule -Name $RequiredModuleName -AllVersions
6375
```
64-
3. Retry update from portal
76+
6577

6678
## If the only version of Az.Accounts is 4.0.2 on the system, check access control
6779
***

0 commit comments

Comments
 (0)