Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Re: Send command line via WMI - Pipe output to text file on remote

Reply
 
Old 09-26-2008   #1 (permalink)
Shay Levy [MVP]


 
 

Re: Send command line via WMI - Pipe output to text file on remote


It works in CTP2 :-)

Try this:

trap { continue }
while ([diagnostics.process]::GetProcessById($processId,$computerName)) {sleep
1}
"process is gone"





---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar



R> Hi Shay,
R>
R> I'm using the code you provided me to monitor a process, how can i
R> supress the error when the process finally ends?
R>
R> while
R> ([diagnostics.process]::GetProcessById($processId,$computerName))
R> {sleep 1}
R>
R> Soon as the process ends it spits out a nice little error:
R> Exception calling "GetProcessById" with "2" argument(s): "Process
R> with an Id
R> of
R> 972 is not running."
R> "Shay Levy [MVP]" wrote:
R>
Quote:
Quote:

>> Try this:
>>
>> try {
>> while
>> ([diagnostics.process]::GetProcessById($results.processId,$serverName
>> ))
>> {sleep 1}
>> } catch {
>> continue;
>> }
>> "process has exited"
>>
>> ---
>> Shay Levy
>> Windows PowerShell MVP
>> http://blogs.microsoft.co.il/blogs/ScriptFanatic
>> PowerShell Toolbar: http://tinyurl.com/PSToolbar
>> R> How about the .net code?
>> R>
>> R> example:
>> R> $tpid = [diagnostics.process]::start("notepad.exe")
>> R> $tpid.WaitForExit()
>> R> "sapienscripter" wrote:
>> R>
Quote:

>>>> After you kick off the remote process use the Start-Sleep cmdlet to
>>>> pause script execution for as long as you think it will take for
>>>> the vmrun command to complete.
>>>>
>>>> -- sapienscripter
>>>>
>>>> Now Available: '-Managing Active Directory with Windows PowerShell:
>>>> TFM-'
>>>> (http://www.scriptingoutpost.com/p-39...-directory-wit
>>>> h- windows-powershell-tfm.aspx)
>>>>
>>>> [image: http://www.scriptinganswers.com/_images/logo_mvp.gif]
>>>>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
how to log output from a command line program VB Script
Send command line via WMI - Pipe output to text file on remote mac PowerShell
Pipe a pipe command to a file VB Script
Suppress output from a command line tool PowerShell
Output Event Log From Command Line Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46