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

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?

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

The problem is that UserAssignedIdentity is still in preview and apparently is not included in AzureRM package.
The following steps made it work for me:
Move to Az package (note - you need uninstall AzureRM first!). It still doesn't include New-AzUserAssignedIdentity.
Install Az.ManagedServiceIdentity directly by running this command:
Install-Module -Name Az.ManagedServiceIdentity
Enjoy!

Related

How to fix powershell after installing VS Code

I already was asking a similar question here: https://superuser.com/questions/1613630/most-of-powershell-commands-not-working?noredirect=1
Basically, I wasn't able to fix the issue so I got a replacement computer. Brand new. Started setting it up and only did the following:
Installed VS Code
Turned on Powershell extension in VS Code
It prompted something about Package Manager needing an update or it will not work properly
Asked me to install NuGet to get the Package Manager
After that PowerShell 5.1 stopped working again.
Modules not autoloading, fresh instance of powershell does this:
PS C:\WINDOWS\system32> Write-Host
Write-Host : The term 'Write-Host' 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
+ Write-Host
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Write-Host:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Any ideas?
This fixed it for me:
(Get-Module -ListAvailable).Name | %{Import-Module -Name $_ -Force}
[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12
Install-Module -Name PackageManagement -Force -RequiredVersion 1.4.6 -Scope AllUsers -AllowClobber -Verbose
Then if the last command doesn't install NuGet do this:
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

'New-SelfSignedCertificate' is not recognised as the name of a cmdlet [duplicate]

On a Windows 7 Professional system, it seems not possible to run New-SelfSignedCertificate. I could on a Windows 10 system.
Yes, the shell was started with "Run As Administrator."
PS C:\> new-selfsignedcertificate
new-selfsignedcertificate : The term 'new-selfsignedcertificate' 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-selfsignedcertificate
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (new-selfsignedcertificate:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10586 117
As stated in the comments above, this isn't available in Windows 7.
However, if you're looking for something with a similar API and capability, then I have used & can recommend this from Microsoft Script Centre:
https://gallery.technet.microsoft.com/scriptcenter/self-signed-certificate-5920a7c6
Have to install AzureRM module to use azure commands through powershell. You can use below command to do it.
Install-Module -Name AzureRM -AllowClobber

The term 'Set-AzureKeyVaultKeyAttributes' is not recognized as the name of a cmdlet,

On my Windows 10 I've Powershell 5.0 installed. But when I run the following command on it, I get the above error.
PS command:
Set-AzureKeyVaultKeyAttributes -Name Key2 -VaultName KayVault-abctest -Enable $false
Error
Set-AzureKeyVaultKeyAttributes : The term 'Set-AzureKeyVaultKeyAttributes' 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
+ Set-AzureKeyVaultKeyAttributes -Name Key2 -VaultName KayVault-abctest ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-AzureKeyVaultKeyAttributes:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Note
I'm using the topic Create a Key (Portal) in this official Azure lab tutorial.
I believe the name of the cmdlet should be the singular Set-AzureKeyVaultKeyAttribute, rather than the plural Set-AzureKeyVaultKeyAttributes. Note that this is one of the Strongly Encouraged Development Guidelines for Powershell by Microsoft:
To enhance the user experience, the noun that you choose for a cmdlet name should be singular. For example, use the name Get-Process instead of Get-Processes. It is best to follow this rule for all cmdlet names, even when a cmdlet is likely to act upon more than one item.
If you are still seeing the same problem while using a singular name, ensure that the AzureRM.KeyVault module is installed and loaded:
Install-Module AzureRM.KeyVault
Import-Module AzureRM.KeyVault

Get-AzureRmResourceGroup : The term 'Get-AzureRmResourceGroup' is not recognized as the name of a cmdlet

I'm trying to retrieve a resource group name from my Azure subscription in PowerShell:
Get-AzureRmResourceGroup | select resourcegroupname
But I get the following error:
Get-AzureRmResourceGroup : The term 'Get-AzureRmResourceGroup' 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
+ Get-AzureRmResourceGroup | select resourcegroupname
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-AzureRmResourceGroup:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I have PowerShell 5.0 and have imported the latest Azure module. Why is this not included?
You need to get the Azure RM module installed first by using the following command:
Install-Module AzureRM
Then you need to import the module for use:
Import-Module AzureRM
I was missing the AzureRM dependency so I had to run the following command: Install-AzureRM. Afterwards, Get-AzureRmResourceGroup | select resourcegroupname executed successfully.

Cannot find an overload for "SoftwareIdentity"

I'd like to use functionality from the latest Azure Powershell library but I'm struggling to install it. This is on an AWS x64 Windows 2012 R2 Standard server.
I get the following error
PS C:\Users\Administrator> Install-Module -Name AzureAD
WARNING: Cannot find an overload for "SoftwareIdentity" and the argument count: "17".
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'AzureAD'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1:1809 char:21
+ $null = PackageManagement\Install-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
ception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
This is with PSVersion = 4.0
Get-Module shows: 3.1.0.0 Microsoft.PowerShell.Management, 3.1.0.0 Microsoft.PowerShell.Utility Script, 1.1.1.0 PackageManagement Script, 1.1.2.0 PowerShellGet
Get-PSRepository shows PSGallery Untrusted https://www.powershellgallery.com/api/v2/
Do you have any pointers to help troubleshoot / fix please?
Thanks
Ok so I installed Win8.1AndW2K12R2-KB3134758-x64.msu from https://www.microsoft.com/en-us/download/details.aspx?id=50395
Now Get-Module returns nothing and the first time I tried Install-Module -Name AzureAD it moaned about the -Name parameter. Second time (which I'm assuming means I'm imagining the first time) it worked. Now to see if I can add a user to an Azure AD group using the latest OpenICF connector scripts.