I am trying to run this command within an Azure Run book
(Get-AzureRmStorageAccountKey -Name $defaultStorageAccountName -ResourceGroupName $defaultResourceGroupName).Value[0]
It runs fine on my local machine and I can see the Storage Account Key. However, when I run the same command in Azure Runbook it throws the following error
Cannot index into a null array
If I just run Get-AzureRmStorageAccountKey -Name $defaultStorageAccountName -ResourceGroupName $defaultResourceGroupName in the Azure Runbook, it runs fine and I can see the Keys. It is just when I am selecting an element from an Array that it fails and throws an error.
The PowerShell version is 5 on my local machine and on Azure Runbook.
Update:
My issue was resolved after updating the Modules from the Gallery in my automation account.

get-member -inputobject (Get-AzureRmStorageAccountKey -Name $defaultStorageAccountName -ResourceGroupName $defaultResourceGroupName).Valueand post the result - 4c74356b41get-member : You must specify an object for the Get-Member cmdlet- janevaluetry doingget-member -inputobject (Get-AzureRmStorageAccountKey -Name $defaultStorageAccountName -ResourceGroupName $defaultResourceGroupName)and see all the properties that exist - 4c74356b41Equals 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;}- jane