Hi,
I have a csv file where multiple columns are present, I would like to get the csv output using VM Name and results only.
from the below script, I am getting the output appended to existing CSV, But I need VMName and results, please help!
Import-Csv -Path $reportlocation1 -UseCulture -PipelineVariable row |
ForEach-Object -Process {
try
{
$session = New-SSHSession $row.Name -Credential $Cred -AcceptKey -ErrorAction Stop
$result = $session | Select-Object -ExpandProperty Connected
$output = $((Invoke-SSHCommand -SSHSession $session -Command 'uptime -s').output)
Get-SSHSession | Remove-SSHSession | Out-Null
}
catch
{
$result = 'False'
}
$row | Add-Member -MemberType NoteProperty -Name 'SSH Login' -Value $result -PassThru | Add-Member -MemberType NoteProperty -Name 'Uptime' -Value $output -PassThru
} | Export-Csv -Path $reportlocation2 -NoTypeInformation -UseCulture