Format output from Variables Table-View in PowerShell

Markus Sacramento

Retrieves information from a CSV-file. I store the values like this:

Foreach($FlexVPN in $FlexVPNlist) {

    # Number of pings
    $Ping = $FlexVPN.'Priority'

    $Test = New-Variable -Name $FlexVPN.'IP-adress' -Value (New-Object PSObject -Property @{
    IP = $FlexVPN.'IP-adress'
    Information = $FlexVPN.'Information'
    Priority = $FlexVPN.'Priority'
    ResponseTime = $Result = Test-Connection -ComputerName $FlexVPN.'IP-adress' -Count $FlexVPN.'Priority' -ea silentlycontinue | Select ResponseTime})

I would like to output in code window the information in a tableview.

Using Write-Host $FlexVPN.'IP-adress' "," $FlexVPN.'Information' "," $FlexVPN.'Priority' "," $Result.ResponseTime

Gives me the data but not the structure I want.

How should I do to format it in tableview?

programmer365

Use a PSCustomObject for this:

[PSCustomObject]@{
  "IP address" = $FlexVPN.'IP-adress'
  "Information" = $FlexVPN.'Information'
  "Priority" = $FlexVPN.'Priority'
  "Response time" = $Result.ResponseTime
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related