Azure PowerShell命令在ISE中无法运行

5

似乎Windows Azure Powershell控制台与ISE没有相同的配置。

例如,在打开控制台窗口后,以下命令有效:Get-AzureVMImage

现在当我进入ISE打开应用程序时,找不到相同的命令。

Get-AzureVMImage : The term 'Get-AzureVMImage' 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.

我可以看到控制台窗口包含以下模块:

ModuleType Name                                ExportedCommands
---------- ----                                ----------------
Binary     Azure                               {Add-AzureAccount, Add-AzureCacheWorkerRole, Add-AzureCertificate, Ad...
Manifest   Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest   Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-Authe...
Manifest   Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}

ISE显示Azure模块缺失。
ModuleType Name                                ExportedCommands                                                                                                     
---------- ----                                ----------------                                                                                                     
Script     ISE                                 {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}                                                                  
Manifest   Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                                                   
Manifest   Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}                            
Manifest   Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                                            
Binary     Microsoft.WindowsAzure.Commands     {Get-AzureAutomationAccount, Get-AzureAutomationJob, Get-AzureAutomationJobOutput, Get-AzureAutomationRunbook...}    
Manifest   Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}                                      

因此,我获取Azure模块的路径,并像下面这样导入它:

Import-Module "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\ServiceManagement\Azure\Microsoft.WindowsAzure.Commands.dll"

但是 Get-AzureVMImage 仍然无法工作。我该如何让 PowerShell 和 ISE 行为完全相同?

谢谢。


很抱歉,我没有意识到您正在比较Azure管理控制台和ISE。考虑到您实际上并未使用标准控制台,我的回答不太好,因此我将其删除。我的建议是运行Azure管理控制台运行的脚本以加载模块,而不仅仅在ISE中手动加载它。 - TheMadTechnician
1个回答

9
安装Azure Powershell命令后,需要重新启动计算机,这样ISE才能看到所有Azure cmdlets。无需运行Import-Module。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接