{"id":300,"date":"2011-04-14T21:48:00","date_gmt":"2011-04-14T11:48:00","guid":{"rendered":"http:\/\/threemillion.net\/blog\/?p=300"},"modified":"2014-12-16T10:56:23","modified_gmt":"2014-12-15T23:56:23","slug":"powershell-transcripts","status":"publish","type":"post","link":"https:\/\/threemillion.net\/blog\/?p=300","title":{"rendered":"Powershell Transcripts"},"content":{"rendered":"<p>I am learning Powershell and came across a post somewhere, apologies however I do not recall where I found it, where you can capture a transcript of your Powershell session. A transcript provides the ability to record your Powershell session to a text file. This includes not only all the commands you type but also the output that appears in the Powershell console window. I find this exceedingly useful when trying different things and then a couple of days later trying to remember what I did. Now that I have a transcript I can simply search the transcript files. <\/p>\n<p>I have added the Start-Transcript to my profile and you can too.<\/p>\n<p>In your profile you can put any Powershell commands you like in there to run every time you start a Powershell console. So for example every time I open a Powershell window I would like to navigate to my scripts directory.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$ScriptDir = &quot;D:\\Scripts\\Powershell&quot;\r\nSet-Location -Path $ScriptDir\r\n<\/pre>\n<p>For the transcript recording, I use the date so that if I know i did something a couple of days ago I know which file to look in. I use the time as well so that if I start multiple Powershell sessions at once they each get a different transcript file. Multiple Powershell sessions can not share a transcript file and it is unlikely that you would start more than one in a second and if you do well, tuff.  \ud83d\ude42<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n#If this is the ISE do not start a transcript\r\nif ($Host.Name -eq &quot;ConsoleHost&quot;)\r\n{\r\n    #Start a transcript file\r\n    $ISODateTime = Get-Date -uFormat &quot;%Y-%m-%d-%H-%M-%S&quot;\r\n    $TranscriptFile = &quot;$($ScriptDir)\\Transcripts\\$($ISODateTime).ps1&quot;\r\n    Start-Transcript -path $TranscriptFile -append\r\n} #end if powershell host\r\n<\/pre>\n<p>I have named my transcript files .ps1 simply so that my text editor syntax highlighting works to make it easier to find cmdlet names and variables. I guess really I should set it to .txt however if you accidentally double click a ps1 it doesn&#8217;t run anyway. A great little safety feature built in by the Powershell team.<\/p>\n<p>With these two bits in my Powershell profile I have found this to be invaluable in my learning. I hope it will help you too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am learning Powershell and came across a post somewhere, apologies however I do not recall where I found it, where you can capture a transcript of your Powershell session. <a href=\"https:\/\/threemillion.net\/blog\/?p=300\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[8],"tags":[70],"class_list":["entry","author-admin","post-300","post","type-post","status-publish","format-standard","category-powershell","tag-transcript"],"_links":{"self":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=300"}],"version-history":[{"count":8,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/300\/revisions"}],"predecessor-version":[{"id":565,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/300\/revisions\/565"}],"wp:attachment":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}