Azure Powershell Cmds在ISE中不起作用

Chi*_*ago 5 powershell azure

似乎Windows Azure Powershell控制台与ISE的配置不同.

例如,在打开控制台窗口后,以下cmdlet可以正常工作:Get-AzureVMImage

现在当我输入ISE打开ISE应用程序时,找不到相同的cmdlet.

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.
Run Code Online (Sandbox Code Playgroud)

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

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...}
Run Code Online (Sandbox Code Playgroud)

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...}                                      
Run Code Online (Sandbox Code Playgroud)

所以我得到了Azure模块的路径并像这样导入它:

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

但是Get-AzureVMImage仍然不起作用.如何使shell和ISE的行为完全相同?

谢谢

irh*_*ric 9

事实证明,您需要在安装Azure Powershell命令后重新启动,然后ISE将看到所有Azure cmdlet.无需运行Import-Module.