Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting first value in a returned object with powershell

I am using the command:

$hostnames = Get-AzureRmWebApp -ResourceGroupName "app-rg" -Name "app" |
               Select-Object -Property hostnames

To return the list of hostnames with an azure web app as below:

HostNames : {a.arup.com, a.internet.trafficmanager.net, a.azurewebsites.net}

However, I am interested in getting the first domain (a.arup.com). How would this be done with powershell?

like image 891
GurdeepS Avatar asked Jul 12 '26 02:07

GurdeepS


1 Answers

There is always an alternative in PowerShell:

$hostnames = Get-AzureRmWebApp -ResourceGroupName "app-rg" -Name "app" |
           Select-Object -ExpandProperty hostnames -First 1