Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


May 15, 2008

Q. Can I keep a log of all the actions in a Windows PowerShell session?


RSS
Subscribe to Windows IT Pro | See More Scripting Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

A. Yes, PowerShell can create a transcript of all session activity through the transcript cmdlets.

To start logging session information, execute the Start-Transcript command, run the commands you want to capture, then run the Stop-Transcript command. By default, PowerShell will store the transcripts in a Users\\Documents\PowerShell_transcript.<datetime>.txt folder. You can specify a different file by passing the new filename to the Start-Transcript command. The following code shows how to use the transcript cmdlets to create and store a PowerShell session transcript. The first command I entered was:

Users\john> Start-Transcript

The output was:

Transcript started, output file is C:\Users\john\Documents\PowerShell_transcript.20080504100855.txt

Then I entered:

Users\john> get-process w*

The output was:

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
103 8 1932 5140 60 0.17 584 wininit
130 7 3092 7456 62 0.39 772 winlogon
938 47 27140 33196 168 2.65 2412 winss
136 12 5236 9020 85 0.39 4040 winssnotify
262 16 5432 9988 85 0.14 4784 WLLoginProxy
123 8 3744 7024 47 0.05 2200 WmiPrvSE
127 7 4004 8044 47 0.11 2956 WmiPrvSE
866 54 46980 69544 221 29.87 4816 wmplayer

Next I entered:

Users\john> date

The output was:

Sunday, May 04, 2008 10:09:23 AM

Then I entered:

Users\john> stop-transcript

The output was:

Transcript stopped, output file is C:\Users\john\Documents\PowerShell_transcript.20080504100855.txt

Next I entered:

Users\john> type C:\Users\john\Documents\PowerShell_transcript.20080504100855.txt

The output was:

**********************
Windows PowerShell Transcript Start
Start time: 20080504100855
Username : SAVILLTECH\john
Machine : SAVDALWKS20 (Microsoft Windows NT 6.0.6001 Service Pack 1)
**********************
Transcript started, output file is C:\Users\john\Documents\PowerShell_transcript.20080504100855.txt

Users\john> get-process w*

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
103 8 1932 5140 60 0.17 584 wininit
130 7 3092 7456 62 0.39 772 winlogon
938 47 27140 33196 168 2.65 2412 winss
136 12 5236 9020 85 0.39 4040 winssnotify
262 16 5432 9988 85 0.14 4784 WLLoginProxy
123 8 3744 7024 47 0.05 2200 WmiPrvSE
127 7 4004 8044 47 0.11 2956 WmiPrvSE
866 54 46980 69544 221 29.87 4816 wmplayer

Users\john> date

Sunday, May 04, 2008 10:09:23 AM

Users\john> stop-transcript

**********************
Windows PowerShell Transcript End
End time: 20080504100927
**********************

End of Article



Reader Comments
I doubt if the output is exactly as described. Did John proof read the article before he submitted it?

ts67 May 21, 2008 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
WinInfo Short Takes: Week of November 24, 2008

An often irreverent look at some of the week's other news, including a Vista Capable dismissal request, Zune price reductions, Morrow musings, Novell and Microsoft sitting in a tree ... two years later, Yahoo!, IE 6 on Windows Mobile, and so much more ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events PowerShell 101 - eLearning Series

Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing