【发布时间】:2017-11-07 12:27:57
【问题描述】:
我正在尝试在 Azure 运行手册中运行此命令
(Get-AzureRmStorageAccountKey -Name $defaultStorageAccountName -ResourceGroupName $defaultResourceGroupName).Value[0]
它在我的本地机器上运行良好,我可以看到存储帐户密钥。但是,当我在 Azure Runbook 中运行相同的命令时,它会引发以下错误
Cannot index into a null array
如果我只是在 Azure Runbook 中运行 Get-AzureRmStorageAccountKey -Name $defaultStorageAccountName -ResourceGroupName $defaultResourceGroupName,它运行良好并且我可以看到密钥。只是当我从 Array 中选择一个元素时,它会失败并引发错误。
我的本地计算机和 Azure Runbook 上的 PowerShell 版本为 5。
更新:
在我的自动化帐户中更新库中的模块后,我的问题得到了解决。
【问题讨论】:
-
尝试
get-member -inputobject (Get-AzureRmStorageAccountKey -Name $defaultStorageAccountName -ResourceGroupName $defaultResourceGroupName).Value并发布结果 -
我已经运行了你建议的命令,它抛出了这个错误
get-member : You must specify an object for the Get-Member cmdlet -
好吧,没有名为
value的属性尝试执行get-member -inputobject (Get-AzureRmStorageAccountKey -Name $defaultStorageAccountName -ResourceGroupName $defaultResourceGroupName)并查看所有存在的属性 -
我得到的输出是
Equals Method bool Equals(System.Object obj) tem.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() ToString Method string ToString() Key1 Property string Key1 {get;set;} Key2 Property string Key2 {get;set;}
标签: powershell azure azure-powershell