PSexec copyright output
Asked Answered
H

6

11

Does anyone know, how to disable "copyright header" from appearing when running PSExec? Everutime I run "./psexec ..." command I see this message:

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

It's really annoying and it bloats up output of my script.

Thanks
Matthew

Headstone answered 12/5, 2015 at 13:56 Comment(0)
M
9

There does not appear to be a way to disable it from occurring, but as a workaround you could redirect STDERR which will suppress the output,

psexec \\remotemachine command 2>nul
Maharashtra answered 12/5, 2015 at 14:0 Comment(0)
M
24

PsExec v2.2 comes with -nobanner option.

Mail answered 19/1, 2018 at 8:20 Comment(0)
M
9

There does not appear to be a way to disable it from occurring, but as a workaround you could redirect STDERR which will suppress the output,

psexec \\remotemachine command 2>nul
Maharashtra answered 12/5, 2015 at 14:0 Comment(0)
R
3

Or better you can do

set F1=find /v "PsExec v2.11 - Execute processes remotely"
set F2=find /v "Copyright (C) 2001-2014 Mark Russinovich"
set F3=find /v "Sysinternals - www.sysinternals.com"
set FILTER=%F1%^|%F2%^|%F3%

psexec \\remotemachine command 2>&1 | %FILTER%
Resemble answered 2/3, 2016 at 11:15 Comment(0)
I
3

I know this is a rather old question, but since it's tagged PowerShell and there hasn't been a PowerShell specific response, here goes:

I wanted to get the value of the environment variable %SystemRoot% on a remote machine, without enabling WinRM.
My invocation in PowerShell was:
$ret = & PsExec.exe \\RemoteMachine powershell.exe -Command '$env:SYSTEMROOT'

This returned an array of type Object[], with one element per line of output received. Sample output, with corresponding array index:

PS> $ret
(0)
(1) PsExec v2.2 - Execute processes remotely
(2) Copyright (C) 2001-2016 Mark Russinovich
(3) Sysinternals - www.sysinternals.com
(4)
(5) C:\WINDOWS

As you can see my desired output was the 6th value in the returned array.

This does also work with PowerShell scripts or commands that output more than one line, as each printed line is appended to the array as a new element.

With that in mind we can tidy our returned output up with the following:
$ret = $ret[5..($ret.Count - 1)]

This basically just removes the first five elements.

I have not tested this solution with programs other than PowerShell though, so use with care.

Instate answered 23/3, 2017 at 13:54 Comment(1)
you sir, saved me some serious time and head scratching on this one. ta!Aleksandropol
A
2

Did you try this:

psexec.exe -nobanner -accepteula
Adanadana answered 29/12, 2020 at 12:50 Comment(0)
H
0

Its work for me:

(.\PsExec.exe -h \\$Server powershell -ExecutionPolicy ByPass -NoProfile -NonInteractive -NoLogo -File "C:\$WorkFolder\$File") | Findstr /v "Sysinternals" | Findstr /v "PsExec" | Findstr /v "Russinovich"
Handlebar answered 23/10, 2023 at 20:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.