I am trying to run a powerhsell script (my_script). The script is stored in this_folder
on the desktop. I am executing the command at the the correct path by using C:\Users\me\desktop\this_folder>.\my_script
. When I try to do this I get the error
The term 'Add-AzureRmAccount' 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
I know that the Add-AzureRmAccount
is a part of the AzureRM.Profile
module. When I got to the modules folder, I see that AzureRM.Profile
is listed. To get these modules, I ran Install-Module -name AzureRM
and Import-module AzureRM
.
Any ideas what might be going on?
---Update--- When I ran Get-Module
commands I saw that only that AzureRM module was listed. I thne tried to run Install-Module -Name AzureRM.Profile
and got the error:
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
Since I see the AzureRM.Profile
folder with a nupkg
at one of the paths listed by $env:PSModulePath
I thought I could just run Import-Module -Name AzureRM.Profile
and I get the error
import-module : The specified module 'AzureRM.Profile' was not
loaded because no valid module file was found in any module directory.
Any ideas?
You say that you've installed and imported the AzureRM module, but have you connected the Azure account with the Connect-AzureRmAccount
cmdlet? I know a number of other modules does not expose all of the available cmdlets until there is an active connection to an account/subscription.
Be aware that scripts can ignore the context in which they are run so you might need to add the following to the start of the script:
Import-Module AzureRM
Connect-AzureRmAccount
Rather than running them manually in the console and then running the script.
You might want also want to look at using the Az module instead as the AzureRM module is being retired, and will only get bug-fixes till the end of December 2020: Introducing the new Azure PowerShell Az module
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.