Powershell ';新AzureStorageContext';不被承认
我正在尝试运行在同事的计算机上运行的PowerShell脚本,但在我的计算机上失败,原因如下:Powershell ';新AzureStorageContext';不被承认,powershell,azure,Powershell,Azure,我正在尝试运行在同事的计算机上运行的PowerShell脚本,但在我的计算机上失败,原因如下: Set-Variable -Name StorageContext -Value (New-AzureStorageContext -ConnectionString $storageConnectionString) 我的错误是: New-AzureStorageContext:术语“New-AzureStorageContext”不能识别为cmdlet、函数、脚本文件或可操作程序的名称。检查名称
Set-Variable -Name StorageContext -Value (New-AzureStorageContext -ConnectionString $storageConnectionString)
我的错误是:
New-AzureStorageContext:术语“New-AzureStorageContext”不能识别为cmdlet、函数、脚本文件或可操作程序的名称。检查名称的拼写或路径是否正确
包括,请验证路径是否正确,然后重试。
在C:\Users\dlogg\Documents\Repos\sd2\PowerShell Scripts\Eco\AddEco.ps1:22 char:43
+设置变量-Name StorageContext-Value(新AzureStorageContext-ConnectionStr
我已经确认我有PowerShell v.3,并且我已经从Web PI安装了带有Microsoft Azure SDK和Microsoft Azure PowerShell(独立)的Azure PowerShell。我需要安装什么才能使用它
更新:根据下面的请求,我已经包含了Get模块的输出:
ModuleType Name ExportedCommands
---------- ---- ----------------
Script Common {Fetch, Get-BlobContainer, Get-ConfigurationFileName, Get-DeploymentTenantListFileName...}
Script ISE {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}
Manifest Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
您正在使用哪一版本的Azure PowerShell模块?您是否已加载Azure模块,或只是在运行PowerShell(或通过Azure PowerShell快捷方式)
以下是Azure PowerShell模块0.8.8.1的输出
PS C:\> Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 0.8.8.1 Azure {Add-AzureAccount, Add-AzureCacheWorkerRole, Add-AzureCert...
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest 3.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
PS C:\> New-AzureStorageContext
cmdlet New-AzureStorageContext at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
StorageAccountName:
使用Azure PowerShell cmdlet的最佳方法是直接从安装程序生成的快捷方式启动Azure PowerShell。或者使用导入模块
命令导入Azure PowerShell模块
有关详细说明,请阅读。并选中。您尚未加载Azure PowerShell模块(因此您的列表中缺少该模块)。安装cmdlet时,您还将获得一个新的快捷方式“Microsoft Azure PowerShell”,该快捷方式将自动为您加载模块(并使cmdlet可用)
如果您不想这样做,可以使用此命令将模块导入现有PowerShell会话(请注意,Azure模块的路径可能会因您安装的版本而异)
您需要在microsoft站点中安装azure power shell
它就像一个魔咒从URL安装Microsoft SDK for PowerShell-
重新启动Windows计算机并尝试执行脚本。它将按预期工作我与您有相同的问题。
我的问题是使用了错误的命令:“AzureStorageContext”。它应该是“AzStorageContext”我已经更新了上面的问题,我看到了与您的输出有点不同的东西,有什么想法吗?谢谢!找不到页面。正如您所建议的,对于PowerShell Core Az库,命令是New AzureStorageContext
。因此,会出现混乱,因为New AzureStorageContext
对某些用户有效,而对某些用户无效用户。我试图在发布管道中的Azure Powershell任务上下文中执行这些命令。结果证明AzureStorageContext是我需要使用的,而不是AzureStorageContext。你的回答帮助我找到了答案。谢谢!我想我爱你!离开Azur后,我一直在努力更新旧脚本呃。简单到可以逃避检查。或者运行导入模块-Name Az
,如下所述:
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1"