TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Microsoft > Microsoft Windows Powershell

Notices

Reply
 
Thread Tools Display Modes
Old 26-06-2008, 04:32 PM   #1
Frank
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,


  Reply With Quote
Old 26-06-2008, 04:32 PM   #2
Shay Levi
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>


  Reply With Quote
Old 26-06-2008, 04:32 PM   #3
Marco Shaw [MVP]
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
  Reply With Quote
Reply

Thread Tools
Display Modes


Google
 


All times are GMT +5.5. The time now is 03:09 AM.


vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2008, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional