Thursday, April 26, 2012

Save PowerShell Console session commands and there output in to text file.

 

Hi,

These days i am very busy in some other projects so that's why this months i post only few articles. Sorry for that.

Does anytime you think to save all the commands and there output in to text file? it like storing all of the PowerShell Consoles session data.

If yes and you don't know how to do it , let me explain it.

it is very simple. we just need to use two commands these are: Start-Transcript , Stop-Transcript

Let see how to use it.

Open you Powershell console , and before running or doing anything else , type Start-Transcript and the path to txt file in which you want to save all the output.

Start-Transcript d:\Log.txt

You can notice in below screenshot it is showing that Transcript started and it the output file is D:\Log.txt.

26-04-2012 18-06-03

Now lets run Few Cmdlets.

Dir

26-04-2012 18-08-37

Get-Process

26-04-2012 18-09-31

one wrong command for testing error

26-04-2012 18-10-02

All done now, type Stop-Transcript, cmdlet to stop recording the session. Transcript is stopped and now lets open the Log.txt file and see if that store all the things which we have done in  our PowerShell console session.

26-04-2012 18-11-26

You can see in below screenshot  that everything which we have done is saved in to a text file. :)

 

26-04-2012 18-14-54

Thanks for viewing my blog.

Aman Dhally

2 comments:

  1. Transcripts are a good learning tool. Unfortunately, they aren't supported everywhere. For example, these cmdlets won't work in the ISE. Don't forget to read help for Start-Transcript: you can specify the file name and even append to existing transcripts.

    ReplyDelete
    Replies
    1. HiJeffery,

      thanks for the information. :), and thanks for the Comment.

      aman

      Delete

Note: Only a member of this blog may post a comment.