Monday 2 January 2012

Record your PowerShell sessions


In-case if you want to record your session in PowerShell and wants to take output in a text file for each and every steps that you have done in PowerShell,  below are the steps


In PowerShell run the following command (Change location to wherever you would like)


Start-Transcript c:\Powershell.txt –Append


Now use PowerShell as you usually would, once you are done with PowerShell run the following command 


“Stop-Transcript” (without quotes)


If you now open the “PowerShell.txt” you will see everything you have just done in your PowerShell session.


********************************************
Windows PowerShell Transcript Start
Start time: 20120102173323
Username  : PowerShell User
Machine      : Windows 2008 R2 (Microsoft Windows NT 6.1.7600.0)
********************************************
Transcript started, output file is c:\MySession.txt
[PS] C:\>Get-Mailbox –Identity Daniel


Name                     Alias                ServerName
—-                         —–                 ———-
Daniel                      Dan                  Exchange2010


[PS] C:\>Get-User -Identity Daniel -RecipientTypeDetails


Name               RecipientType
—-                   ————-
Daniel                MailUser


[PS] C:\>Stop-Transcript


Happy Recording :-)