SOLVED

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

Copper Contributor

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

2 Replies
best response confirmed by peter.kiehn (Copper Contributor)
Solution

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.

1 best response

Accepted Solutions
best response confirmed by peter.kiehn (Copper Contributor)
Solution

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.

View solution in original post