Search code examples
powershellazure-powershellpowershell-moduleazure-managed-identityazure-rm

The term 'New-AzureRmUserAssignedIdentity' is not recognized as the name


I'm trying to create user assigned identity, the documentation says that 6.13 should include this function: https://learn.microsoft.com/en-us/powershell/module/azurerm.managedserviceidentity/new-azurermuserassignedidentity?view=azurermps-6.13.0

I uninstalled old versions of Azure RM and installed the latest:

PS C:\Users\user> Get-Module AzureRM -ListAvailable | Select-Object -Property Name,Version,Path

Name    Version Path
----    ------- ----
AzureRM 6.13.1  C:\Program Files\WindowsPowerShell\Modules\AzureRM\6.13.1\AzureRM.psd1

But when I try to use it I get the following error:

PS C:\Users\zakima> New-AzureRmUserAssignedIdentity -ResourceGroupName PSRG -Name ID1
New-AzureRmUserAssignedIdentity : The term 'New-AzureRmUserAssignedIdentity' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ New-AzureRmUserAssignedIdentity -ResourceGroupName PSRG -Name ID1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (New-AzureRmUserAssignedIdentity:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Am I missing some config setting?


Solution

  • The New-AzureRmUserAssignedIdentity Cmdlet resides in the AzureRM.ManagedServiceIdentity module. This module in turn can be found in the PowerShell Gallery and can be installed via:

    Install-Module -Name "AzureRM.ManagedServiceIdentity" -AllowPrerelease
    

    Note that the AllowPrerelease flag for Install-Module might not be available for your installed PowerShellGet version, so you might need to update it before the above would work:

    Install-Module "PowerShellGet" –Repository "PSGallery" –Force