Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : Windows PowerShell print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
The Cmdlets to record a PowerShell session


Bookmark and Share

By: Ying Li
Posted On: 9/17/2007

Sometimes when we write powershell scripts, we will need to test out a lot of lines in the interactive PowerShell session. Once we have the working “lines”, we want to copy them back to the script. You can use edit -select -copy as in DOS. But PowerShell has two builtin cmdlets to help us recording a PowerShell session.

This article was Previously posted on Ying Li's Blog


Start-Transcript – creates a record of all or part of a Windows PowerShell session in a txt file. The transcript includes all command that the user types and all output that appears on the console.

Stop-Transcript – stops a transcript that was started by using the Start-Transcript cmdlet. Of course, you can also stop a stranscript by ending the session.

Here is a sample output file:


Windows PowerShell Transcript Start
Start time: 20070915230637
Username : MAYFLOWER\Ying
Machine : MAYFLOWER (Microsoft Windows NT 5.1.2600 Service Pack 2)

Transcript started, output file is C:\Documents and Settings\Ying\My Documents\
PowerShell_transcript.20070915230637.txt
PS C:\PS> Get-Process svc*

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
228 6 3712 2916 68 1.40 356 svchost
94 5 2316 644 37 0.56 448 svchost
662 15 3292 3376 47 17.76 808 svchost
232 7 3856 1424 48 0.69 996 svchost
1948 94 24368 14688 169 37.35 1512 svchost
133 3 3000 148 39 0.39 1836 svchost
156 4 3264 1060 45 1.91 2084 svchost
101 12 2112 180 43 1.15 2772 svchost


PS C:\PS> stop-process

cmdlet stop-process at command pipeline position 1
Supply values for the following parameters:
Id[0]: PS C:\PS> Stop-Transcript

Windows PowerShell Transcript End
End time: 20070915230700

Is this cool or what?



  myITforum.com ©2010 | Legal | Privacy