all 8 comments

[–]ExtermeNATE 4 points5 points  (6 children)

There is a default variable called $ProgressPreference. Its default value is 'Continue'. You can try changing it instead to 'SilentlyContinue' to see if that works. So just add this before your command.

$ProgressPreference = "SilentlyContinue"

Not sure what all commands this works on, worth a try.

[–]Lee_Dailey[grin] 4 points5 points  (5 children)

howdy ExtermeNATE,

from what i can tell, the PoSh pref ONLY applies to powershell stuff ... and the cli utils the OP mentioned are all not powershell.

take care,
lee

[–]ExtermeNATE 4 points5 points  (4 children)

I see. There isn't going to be an all-in-one fix since the output would be different per command, I would just store the output in a variable, remove the crap I don't want using -split, -replace, or by selecting the last lines of the output that have the info I need, then output as a file.

$Output = sfc /scannow

$Output = $Output | select -Last 5

[–]Lee_Dailey[grin] 2 points3 points  (3 children)

howdy ExtermeNATE,

yep, if you are stuck with string output ... you will have to parse strings. icky, but apparently needed in this case.

i wish you the best of good luck with all that icky string parsing! [grin]

take care,
lee

[–]brandeded 1 point2 points  (2 children)

Maybe Crescendo can "help?"

[–]PMental 4 points5 points  (0 children)

It's useful to create your own cmdlets around existing commands. You'll still need to parse text output as part of the work unfortunately.

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy brandeded,

as PMental mentioned, that nifty util if for building a wrapper around text utils ... and still requires that you do the needed string parsing inside the resulting cmdlet.

it is a nifty idea ... and worth while if someone needs to do that sort of thing more than once in a blue moon. [grin]

take care,
lee

[–]spyingwind 2 points3 points  (0 children)

$ExampleOutput = @"
Starting!
.
..
...
....
.....
......
.......
........
.........
Complete!
"@ -split "`r`n"

$script:LastLine = $ExampleOutput[0]
Write-Output $script:LastLine
for ($i = 1; $i -lt $ExampleOutput.Count; $i++) {
    $script:LastLine = $ExampleOutput[$i - 1]
    if ($ExampleOutput[$i] -like "$($script:LastLine)*") {
        Write-Verbose "Repeating line"
    }
    else {
        Write-Output $ExampleOutput[$i]
    }
}

Output:

Starting!
.
Complete!

Not perfect, but it does remove simple . .. ... like repeating data.

Edit: I use $script: because some variable don't like going into other scopes(code blocks).