none
Getting system.Collections.hashtable output in Powershell v2.0 RRS feed

  • Question

  • Hi All,

    I am new to Powershell scripting. I am facing the below issues as below,

    function Get-SqlServerInstance
    {

    ...........................

    ...........................

    [PSCustomObject] @{
                                ComputerName = $computer
                                ServerInstance = $fullname -replace "\\MSSQLSERVER"
                                InstanceName = $instancename
                                ClusterName = $clusname
                                ClusterInstance = if ($sqlbasekey.OpenSubKey($inskey + "\Setup").GetValue('SQLCluster') -eq '1') {$true} else {$false}                           
                                DefaultInstance = if ($fullname -match "\\MSSQLSERVER") {$true} else {$false}
                                    }

    I am trying the assign the above multiple outputs to a single variable with below line

    $A = Get-SQLServerInstance -ComputerName $env:computername (Multiple servers instances details)

    Write-Host $A

    which is working fine with latest powershell versions systems but not collecting the data in 2.0 version (Getting system.Collections.hashtable output). May I know how to handle this, Thanks for you help

    David

    Tuesday, July 9, 2019 5:01 PM

Answers

All replies

  • PS 2 does  not support that syntax.  PS 2 is obsolete and should not be used on any system for security reasons.

    In PS2 you will have to hand build your objects.


    \_(ツ)_/

    Wednesday, July 10, 2019 3:04 AM
  • Thanks JRV!

    May I know how to do it could you give me some example please...

    Wednesday, July 10, 2019 3:46 PM
  • help add-member -online

    \_(ツ)_/

    • Marked as answer by SQL_Dave Thursday, October 3, 2019 9:28 AM
    Wednesday, July 10, 2019 6:33 PM