output of below script is showing in hashtable format.
param(
[string[]]$computername
)
foreach($computer in $computername){
$filebeat_status_before = get-service -name filebeat -computername $computer
get-service -name filebeat -computername $computer |Restart-Service
$filebeat_status_after = get-service -name filebeat -computername $computer
$props = [ordered]@{'computername'=$computer;'status_before'=$filebeat_status_before.Status;'status_after'=$filebeat_status_after.status
}
$obj = New-Object -TypeName PSobject -Property $props
write-output "$obj"
}
Output is showing as below
@{computername=XYZ; status_before=Running; status_after=Running}
but it should show as below:
computername = XYZ
status_before = Stopped
status_after = Running
Any thoughts how to fix this output format.