Forum Discussion

peter.kiehn's avatar
peter.kiehn
Copper Contributor
May 18, 2018
Solved

Output parameters from Get-AzureRmLocation| Grid View and set them as variables

Hello Folks,


in a script I must be able to select the Azure region and then set it as a variable. The line looks like this so far:

$Region = Get-AzureRmLocation | Out-GridView -PassThru -Title "Select Your Region"

 

when i print out the value of the command, it looks like this:

 -> Parameter Set to  Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels.PSResourceProviderLocation

Unfortunately this does not correspond to any value that i can use in the script. For example, I should be able to pass the name.

"West Europe"

Thanks for any Ideas.

Greetings
Peter

  • The output of Out-GridView is the full object type, if you want a specific property use this instead:

     

    $Region = Get-AzureRmLocation | Out-GridView -PassThru -Title "Select Your Region" | select -ExpandProperty Name

     

    where Name is the property you need.

  • The output of Out-GridView is the full object type, if you want a specific property use this instead:

     

    $Region = Get-AzureRmLocation | Out-GridView -PassThru -Title "Select Your Region" | select -ExpandProperty Name

     

    where Name is the property you need.

Resources