SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-195194%22%20slang%3D%22en-US%22%3EOutput%20parameters%20from%20Get-AzureRmLocation%7C%20Grid%20View%20and%20set%20them%20as%20variables%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-195194%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Folks%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Ein%20a%20script%20I%20must%20be%20able%20to%20select%20the%20Azure%20region%20and%20then%20set%20it%20as%20a%20variable.%20The%20line%20looks%20like%20this%20so%20far%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%24Region%20%3D%20Get-AzureRmLocation%20%7C%20Out-GridView%20-PassThru%20-Title%20%22Select%20Your%20Region%22%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3Ewhen%20i%20print%20out%20the%20value%20of%20the%20command%2C%20it%20looks%20like%20this%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B-%26gt%3B%20Parameter%20Set%20to%26nbsp%3B%20Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels.PSResourceProviderLocation%3CBR%20%2F%3E%3CBR%20%2F%3EUnfortunately%20this%20does%20not%20correspond%20to%20any%20value%20that%20i%20can%20use%20in%20the%20script.%20For%20example%2C%20I%20should%20be%20able%20to%20pass%20the%20name.%3CBR%20%2F%3E%3CBR%20%2F%3E%22West%20Europe%22%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20for%20any%20Ideas.%3CBR%20%2F%3E%3CBR%20%2F%3EGreetings%3CBR%20%2F%3EPeter%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-195194%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Automation%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-196115%22%20slang%3D%22en-US%22%3ERe%3A%20Output%20parameters%20from%20Get-AzureRmLocation%7C%20Grid%20View%20and%20set%20them%20as%20variables%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-196115%22%20slang%3D%22en-US%22%3E%3CP%3EThx%20a%20lot%20it%20works%20fine.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-195311%22%20slang%3D%22en-US%22%3ERe%3A%20Output%20parameters%20from%20Get-AzureRmLocation%7C%20Grid%20View%20and%20set%20them%20as%20variables%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-195311%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20output%20of%20Out-GridView%20is%20the%20full%20object%20type%2C%20if%20you%20want%20a%20specific%20property%20use%20this%20instead%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%24Region%20%3D%20Get-AzureRmLocation%20%7C%20Out-GridView%20-PassThru%20-Title%20%22Select%20Your%20Region%22%20%7C%20select%20-ExpandProperty%20Name%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ewhere%20Name%20is%20the%20property%20you%20need.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New 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
Highlighted
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.

Highlighted