![]() |
|
|
#1 |
|
Guest
Posts: n/a
|
how to see arguments with powershell when running winrs
Hi,
When running a Powershell script via winrs, is it possible to see what arguments are used so that I can see which Powershell script it is running? ie: winrs /r:testhost powershell.exe -nologo -noprofile c:\test.ps1 when I do get-process on the target host, I get just "powershell" for processname. I would like to see "c:\test.ps1" ie, [C:\]: get-process |?{$_.name -eq "Powershell"} Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 516 21 79204 91616 600 14.29 932 powershell Thanks in advance, |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: how to see arguments with powershell when running winrs
PS > (gwmi win32_process -filter "name='powershell.exe'").commandLine When there is more than one powershell instance running: PS > gwmi win32_process -filter "name='powershell.exe'" | select name,commandLine --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com F> Hi, F> F> When running a Powershell script via winrs, is it possible to see F> what arguments are used so that I can see which Powershell script it F> is running? F> F> ie: F> F> winrs /r:testhost powershell.exe -nologo -noprofile c:\test.ps1 F> F> when I do get-process on the target host, I get just "powershell" for F> processname. I would like to see "c:\test.ps1" F> F> ie, F> F> [C:\]: get-process |?{$_.name -eq "Powershell"} F> F> Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName F> ------- ------ ----- ----- ----- ------ -- ----------- F> 516 21 79204 91616 600 14.29 932 powershell F> Thanks in advance, F> |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: how to see arguments with powershell when running winrs
Frank wrote:
> Hi, > > When running a Powershell script via winrs, is it possible to see what > arguments are used so that I can see which Powershell script it is running? > > ie: > > winrs /r:testhost powershell.exe -nologo -noprofile c:\test.ps1 > > when I do get-process on the target host, I get just "powershell" for > processname. I would like to see "c:\test.ps1" Throw this in your test.ps1: $MyInvocation.MyCommand Example output: CommandType Name Definition ----------- ---- ---------- ExternalScript test.ps1 C:\test.ps1 Id : 828 Handles : 263 CPU : 1.46875 Name : powershell Id : 4176 Handles : 319 CPU : 0.875 Name : powershell So from there, you can go with a specific property that you want to view. Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|