Love to get some feedback on this..

Welcome Forums General PowerShell Q&A Love to get some feedback on this..

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
1 year, 11 months ago.

  • Author
    Posts
  • #60211

    Participant
    Points: 0
    Rank: Member

    Hello,

    Working hard on my PowerShell skills and really enjoying myself in de process. But I was figuring out this one-liner today and thought that this was maybe a bit complicated and should be able to do this easier. So this is why I thought to post my "creation" here.. Again, it's nothing fancy, but I accomplished my goal and just want to know if there was a easier way on doing this..

    So here is my "one-liner" The idea is that I wanted to put my StorageAccountKey in a variable which I then can use. But the hard thing (for me) was to get only the first key, you het two keys when you use the Get-AzureRmStorageAccountkey cmdlet.

    $StorageKey = (Get-AzureRmStorageAccountkey -ResourceGroupName "ResourceGroup" -Name "storageaccount").value | select -First 1

    Like I said, would love to get some feedback on this.

  • #60213

    Participant
    Points: 10
    Rank: Member
    # For Azure PowerShell version 1.4, and later versions
    $StorageKey = (Get-AzureRmStorageAccountkey -ResourceGroupName "ResourceGroup" -Name "storageaccount").value[0]
    # For Azure PowerShell version 1.3.2, and previous versions
    $StorageKey = (Get-AzureRmStorageAccountkey -ResourceGroupName "ResourceGroup" -Name "storageaccount").Key1
    

The topic ‘Love to get some feedback on this..’ is closed to new replies.