{"id":1597,"date":"2011-08-12T10:58:31","date_gmt":"2011-08-12T14:58:31","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=1597"},"modified":"2013-05-08T12:15:06","modified_gmt":"2013-05-08T16:15:06","slug":"friday-fun-export-transcript-to-script","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/","title":{"rendered":"Friday Fun Export Transcript to Script"},"content":{"rendered":"<p>Over the years I've posted variations on this technique and discuss it often in my training classes. The idea is to take your PowerShell transcript and transform it into a PowerShell script. Remember that there is very little difference between running commands in the shell and in a script. Thus, any commands that have been captured by a transcript should be able to be executed in a script.<\/p>\n<p>First you'll need a transcript. At your PowerShell prompt run Start-Transcript. Actually, first look at cmdlet help. I prefer giving my transcript a name.<\/p>\n<pre class=\"lang:ps decode:true\">Start-Transcript c:\\work\\fridayfun.txt<\/pre>\n<p>Now run all the commands that you think you'd like to use in your script. Don't worry if you get errors. Keep working until you get the commands you want. You're going to clean up your script file anyway. If you are done, you can run Stop-Transcript. Or if you close your PowerShell session the transcript will automatically be closed.<\/p>\n<p>Now you're going to need my Export-Transcript function.<\/p>\n<pre class=\"lang:ps decode:true\">Function Export-Transcript {\r\n\r\n[cmdletbinding(SupportsShouldProcess=$True)]\r\n\r\nParam (\r\n[Parameter(Position=0,Mandatory=$True,HelpMessage=\"Enter the path and filename to a PowerShell transcript.\")]\r\n[ValidateNotNullOrEmpty()]\r\n[string]$Transcript,\r\n[Parameter(Position=1,Mandatory=$True,HelpMessage=\"Enter the path and filename for the script.\")]\r\n[ValidateNotNullOrEmpty()]\r\n[string]$Script,\r\n[switch]$NoClobber\r\n)\r\n\r\n#verify transcript file can be found\r\nif (! (test-path $Transcript)) {\r\nWrite-Error \"$Transcript can't be found!\"\r\nReturn\r\n}\r\n\r\n#define an array for the script content\r\n$content=@()\r\n\r\n#define a script header\r\n$header=@\"\r\n#Requires -version 2.0\r\n\r\n&lt;#\r\n$(\"#\"*100)\r\nName : $(Split-Path -Path $Script -Leaf)\r\nCreated: $(Get-Date)\r\nSource : $Transcript\r\nAuthor : $env:username\r\nCompany: $env:userdomain\r\n\r\nPSVersionTable\r\n$(($PSVersionTable | Out-String).Trim())\r\n\r\nCurrent Host\r\n$(($host | format-list Name,Version,*Culture | out-String).Trim())\r\n$(\"#\"*100)\r\n#&gt;\r\n\r\nSet-StrictMode -Version Latest\r\n\r\n\"@\r\n\r\n#add the header to content\r\n$content+=$header\r\n\r\nWrite-Verbose \"Filtering content from $Transcript\"\r\n$filteredLog=Get-Content $Transcript | Select-String \"&gt; \"\r\n\r\nWrite-Verbose \"Processing $($filteredLog.count) command lines\"\r\n\r\n# drop the last line which is likely a stop-transcript command\r\nfor ($i=0;$i -lt $filteredLog.length-1;$i++)\r\n{\r\n#each item in $filteredlog is actually a MatchInfo object which\r\n#we need to treat as a string\r\n$line=$filteredLog[$i].ToString()\r\nWrite-Verbose $line\r\n#find the first &gt; in the line\r\n$idx=$line.IndexOf(\"&gt;\")\r\n#get everything after the first &gt;\r\n$cmd=$line.Substring($idx+1)\r\n#add the line to the new content, trimming off any spaces\r\n$content+=$cmd.Trim()\r\n}\r\n\r\nWrite-Verbose \"Creating script file\"\r\nIf ( (Test-Path -Path $Script) -AND ($NoClobber)) {\r\nWrite-Verbose \"NoClobber specified and file exists.\"\r\nWrite-Warning \"NoClobber specified and $script exists.\"\r\n}\r\nelse {\r\n$content | Out-File -FilePath $Script\r\nWrite-Verbose (\"Finished exporting {0}. See {1} for your script.\" -f $Transcript,$script)\r\nGet-Item -Path $Script\r\n}\r\n\r\n} #end function<\/pre>\n<p>Once the function is loaded into your PowerShell session, run it specifying the transcript and the name of your new script file.<\/p>\n<pre class=\"lang:ps decode:true\">PS C:\\&gt; Export-Transcript c:\\work\\fridayfun.txt c:\\scripts\\MyNewScript.ps1<\/pre>\n<p><span style=\"line-height: 1.714285714; font-size: 1rem;\">The function creates a new script file, overwriting any previous versions unless you use -NoClobber.<\/span><\/p>\n<pre class=\"lang:ps decode:true\">Write-Verbose \"Creating script file\"\r\nIf ( (Test-Path -Path $Script) -AND ($NoClobber)) {\r\nWrite-Verbose \"NoClobber specified and file exists.\"\r\nWrite-Warning \"NoClobber specified and $script exists.\"\r\n}\r\nelse {\r\n$content | Out-File -FilePath $Script\r\nWrite-Verbose (\"Finished exporting {0}. See {1} for your script.\" -f $Transcript,$script)\r\nGet-Item -Path $Script\r\n}\r\n[<\/pre>\n<p>The contents of the script consist of a header that includes a variety of metadata I thought you most likely would want.<\/p>\n<pre class=\"lang:ps decode:true\">#define a script header\r\n$header=@\"\r\n#Requires -version 2.0\r\n\r\n&lt;#\r\n$(\"#\"*100)\r\nName : $(Split-Path -Path $Script -Leaf)\r\nCreated: $(Get-Date)\r\nSource : $Transcript\r\nAuthor : $env:username\r\nCompany: $env:userdomain\r\n\r\nPSVersionTable\r\n$(($PSVersionTable | Out-String).Trim())\r\n\r\nCurrent Host\r\n$(($host | format-list Name,Version,*Culture | out-String).Trim())\r\n$(\"#\"*100)\r\n#&gt;\r\n\r\nSet-StrictMode -Version Latest\r\n\r\n\"@\r\n\r\n#add the header to content\r\n$content+=$header<\/pre>\n<p>The main part of the function gets the transcript content where the line contains the \"&gt;\" character.<\/p>\n<pre class=\"lang:ps decode:true\">Write-Verbose \"Filtering content from $Transcript\"\r\n$filteredLog=Get-Content $Transcript | Select-String \"&gt; \"<\/pre>\n<p><span style=\"line-height: 1.714285714; font-size: 1rem;\">The assumption is that your Powershell prompt, which is captured int he transcript is something like PS C:\\somewhere\\&gt;. The end result is that $FilteredLog contains only the command lines. Don't worry if it captures non-command lines that just might have a ? character since you always need to edit the resulting script file. Think of my function as a rapid prototyping tool; you still need to refine and validate the script.<\/span><\/p>\n<p>Moving on. Each line is then parsed using the Substring method so that it starts at the location of the first &gt; +1 character.<\/p>\n<pre class=\"lang:ps decode:true\"># drop the last line which is likely a stop-transcript command\r\nfor ($i=0;$i -lt $filteredLog.length-1;$i++)\r\n{\r\n#each item in $filteredlog is actually a MatchInfo object which\r\n#we need to treat as a string\r\n$line=$filteredLog[$i].ToString()\r\nWrite-Verbose $line\r\n#find the first &gt; in the line\r\n$idx=$line.IndexOf(\"&gt;\")\r\n#get everything after the first &gt;\r\n$cmd=$line.Substring($idx+1)\r\n#add the line to the new content, trimming off any spaces\r\n$content+=$cmd.Trim()\r\n}<\/pre>\n<p>Each \"command\" is added to the $content array. After everything has been processed $content is written to the new file and presto, chango you have a script! Open the script file in your editor of choice and take it from there. Clean up commands you don't want. Add additional comments. Add help. Fortunately, you've already worked out the majority of code in your PowerShell session so creating a script shouldn't take that much time.<\/p>\n<p>I hope this helps speed up your script development.<\/p>\n<p>Download <a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/08\/Export-Transcript.txt\" target=\"_blank\">Export-Transcript<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the years I&#8217;ve posted variations on this technique and discuss it often in my training classes. The idea is to take your PowerShell transcript and transform it into a PowerShell script. Remember that there is very little difference between running commands in the shell and in a script. Thus, any commands that have been&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[271,75,8],"tags":[224,534,540,316,267],"class_list":["post-1597","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell-v2-0","category-scripting","tag-function","tag-powershell","tag-scripting","tag-start-transcript","tag-transcript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun Export Transcript to Script &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun Export Transcript to Script &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Over the years I&#039;ve posted variations on this technique and discuss it often in my training classes. The idea is to take your PowerShell transcript and transform it into a PowerShell script. Remember that there is very little difference between running commands in the shell and in a script. Thus, any commands that have been...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2011-08-12T14:58:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-05-08T16:15:06+00:00\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1597\\\/friday-fun-export-transcript-to-script\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1597\\\/friday-fun-export-transcript-to-script\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun Export Transcript to Script\",\"datePublished\":\"2011-08-12T14:58:31+00:00\",\"dateModified\":\"2013-05-08T16:15:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1597\\\/friday-fun-export-transcript-to-script\\\/\"},\"wordCount\":432,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"Function\",\"PowerShell\",\"Scripting\",\"Start-Transcript\",\"transcript\"],\"articleSection\":[\"Friday Fun\",\"PowerShell v2.0\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1597\\\/friday-fun-export-transcript-to-script\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1597\\\/friday-fun-export-transcript-to-script\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1597\\\/friday-fun-export-transcript-to-script\\\/\",\"name\":\"Friday Fun Export Transcript to Script &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2011-08-12T14:58:31+00:00\",\"dateModified\":\"2013-05-08T16:15:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1597\\\/friday-fun-export-transcript-to-script\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1597\\\/friday-fun-export-transcript-to-script\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1597\\\/friday-fun-export-transcript-to-script\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun Export Transcript to Script\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Friday Fun Export Transcript to Script &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun Export Transcript to Script &#8226; The Lonely Administrator","og_description":"Over the years I've posted variations on this technique and discuss it often in my training classes. The idea is to take your PowerShell transcript and transform it into a PowerShell script. Remember that there is very little difference between running commands in the shell and in a script. Thus, any commands that have been...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/","og_site_name":"The Lonely Administrator","article_published_time":"2011-08-12T14:58:31+00:00","article_modified_time":"2013-05-08T16:15:06+00:00","author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun Export Transcript to Script","datePublished":"2011-08-12T14:58:31+00:00","dateModified":"2013-05-08T16:15:06+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/"},"wordCount":432,"commentCount":6,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["Function","PowerShell","Scripting","Start-Transcript","transcript"],"articleSection":["Friday Fun","PowerShell v2.0","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/","name":"Friday Fun Export Transcript to Script &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2011-08-12T14:58:31+00:00","dateModified":"2013-05-08T16:15:06+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun Export Transcript to Script"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":4445,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/","url_meta":{"origin":1597,"position":0},"title":"Simulating a PowerShell Demo","author":"Jeffery Hicks","date":"July 13, 2015","format":false,"excerpt":"A number of years ago I published my version of a Start-Demo script. In my version, I can create a text file with all of the commands I want to run. It might look like this: Get-Date get-ciminstance win32_logicaldisk | select DeviceID,Size,Freespace :: get-service | where {$_.status -eq 'running'} |\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1242,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1242\/convert-transcript-to-script\/","url_meta":{"origin":1597,"position":1},"title":"Convert Transcript to Script","author":"Jeffery Hicks","date":"March 21, 2011","format":false,"excerpt":"During my PowerShell scripting best practices at Techmentor last week I mentioned a function I had to convert a PowerShell transcript to a script file. Since there's very little difference between an interactive session and a script, parsing the transcript can yield 80% or more of a script very quickly.\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1473,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1473\/friday-fun-start-typeddemo-v2\/","url_meta":{"origin":1597,"position":2},"title":"Friday Fun: Start-TypedDemo v2","author":"Jeffery Hicks","date":"May 27, 2011","format":false,"excerpt":"Not too long ago I posted a function I wrote for doing PowerShell demonstrations. My goal was to simulate a live interactive demo but without the typing so I could focus on explaining and not typing. The first version was a good start but I always had plans for a\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":917,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/917\/understanding-powershell-background-jobs\/","url_meta":{"origin":1597,"position":3},"title":"Understanding PowerShell Background Jobs","author":"Jeffery Hicks","date":"September 9, 2010","format":false,"excerpt":"Last night I spoke to the CNY .NET Developers Group about background jobs in Windows PowerShell. Even though the audience was primarily developers, I discussed jobs from an administrator's perspective, that is, using cmdlets. The job feature in PowerShell 2.0 is pretty amazing and you don't need any programming skills.\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5789,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5789\/who_is_running\/","url_meta":{"origin":1597,"position":4},"title":"Who is Running Your PowerShell Script?","author":"Jeffery Hicks","date":"November 21, 2017","format":false,"excerpt":"I've often talked about the benefit of including Verbose output in your PowerShell scripts and functions from the very beginning. This is especially helpful when someone else is running your command but encounters a problem. You can have them start a transcript, run your command with \u2013Verbose, close the transcript\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-17.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-17.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-17.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-17.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1454,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1454\/teched-atlanta-managing-the-registry-with-powershell\/","url_meta":{"origin":1597,"position":5},"title":"TechEd Atlanta &#8211; Managing the Registry with PowerShell","author":"Jeffery Hicks","date":"May 23, 2011","format":false,"excerpt":"My second TechEd talk was about managing the registry with Windows PowerShell. If you were in the session you know that I stressed heavily using the PowerShell provider and cmdlets. For remote computers, leverage PowerShell's remoting infrastructure. But I also discussed using the \"raw\" .NET classes as well as WMI\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1597"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1597\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}