This code starts ping
$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo $ProcessInfo.FileName = "ping.exe" $ProcessInfo.RedirectStandardError = $true $ProcessInfo.RedirectStandardOutput = $true $ProcessInfo.UseShellExecute = $false $ProcessInfo.Arguments = "localhost" $Proc = New-Object System.Diagnostics.Process $Proc.StartInfo = $ProcessInfo $Proc.Start() | Out-Null
When I type $ Proc on command:
$Proc
I get this:
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 27 3 1936 1852 10 0.02 6832 PING
What I want to do is get a row of data into a row.
So, I tried this:
$Proc | Format-table -HideTableHeaders
And I got this:
27 3 1936 1852 10 0.02 6832 PING
I tried this:
$Foo = $Proc | Format-table -HideTableHeaders $Foo
And got the following:
Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData
So the question is how ... How do you usually get a good line output from a powershell object into a line?
Ultimately, all I am trying to do is stick to the word START before the normal output, which I get when I simply type $ Proc on the line in my powershell script.
START 27 3 1936 1852 10 0.02 6832 PING
But "Start" + $ Proc produces the following:
Start System.Diagnostics.Process (PING)
So why did I think that I would try to get $ Proc into a string.
source share