I want to query SQL Server in PowerShell using Invoke-DbaSqlCmd.
Invoke-DbaSqlCmd -SqlInstance DBA -Query 'exec xp_fixeddrives'
This will return a System.Data.DataRow object. The object type is not really important. The important thing to know is the result will be different depending on SQL Server language. In French it will be 'Mo disponible' and English will be 'MB Free'. I want my code to work in any SQL Server language available.
I want to select the second column without using Get-Member. Like the solution here:
$RST = Invoke-DbaSqlCmd -SqlInstance DBA -Query 'exec xp_fixeddrives'
$SecondCol = ($RST | Get-Member -MemberType Properties)[1].Name
$RST.$SecondCol
Is there an elegant way of returning the second column without using it's name?