Hello Everyone,
I have following command/code that returns following values:
Host: myappliancename
Output: sometext from the command output
ExitStatus: 0
Get-SSHSession | ForEach-Object {Invoke-SSHCommand -Index $_.SessionID -Command 'showsys' }
When i tried to export the csv with the following command
Get-SSHSession | ForEach-Object {Invoke-SSHCommand -Index $_.SessionID -Command 'showsys' } | export-csv -Path c:\temp\test123.csv -NoClobber -NoTypeInformation
The output in the csv file looks OK for the columns Host, ExitCode but not for the actual output. Actual output shows as “System.String”
any idea how can i generate csv file correctly with those columns. Here is my full script;
#Load the Module
Import-Module Posh-SSH
#Appliance Names
$Appliancenames = "appliance1", "appliance2", "appliance2"
#Enter the admin credentials
$cred = Get-Credential
#Connect and create SSH Session to each appliance
New-SSHSession -ComputerName $Appliancenames -Credential $cred -AcceptKey
#Get Sessions and Execute commands then export csv
Get-SSHSession | ForEach-Object {Invoke-SSHCommand -Index $_.SessionID -Command 'showsys' } | Export-csv -Path c:\temp\test123.csv -NoClobber -NoTypeInformation