{"id":1046,"date":"2011-01-12T08:30:30","date_gmt":"2011-01-12T13:30:30","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=1046"},"modified":"2012-04-07T11:50:59","modified_gmt":"2012-04-07T15:50:59","slug":"convert-history-to-script","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/","title":{"rendered":"Convert History to Script"},"content":{"rendered":"<p>Whenever I teach or speak about PowerShell, a recurring mantra is that there is no difference between running a PowerShell script and executing commands interactively in the shell, except that it saves you typing. You can create a PowerShell script by simply copying and pasting commands from the shell into a .PS1 text file. This means you can develop and test your script as you write it. But copying and pasting can be a pain. One alternative I have is a script to take your PowerShell history and turn it into a script file.<!--more--><br \/>\nWhenever you run a PowerShell command, it is stored in an internal history buffer. We use the <a title=\"Get online help\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113317\" target=\"_Blank\">Get-History<\/a> cmdlet to retrieve history.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nPS S:\\&gt; get-history<\/p>\n<p>Id CommandLine<br \/>\n-- -----------<br \/>\n1 get-date<br \/>\n2 $stats=dir *.ps1 | measure-object -Property Length -sum<br \/>\n3 $stats.count<br \/>\n[\/cc]<br \/>\nYou can also retrieve specific history items by their id number.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nPS S:\\&gt; get-history 3<\/p>\n<p>Id CommandLine<br \/>\n-- -----------<br \/>\n3 $stats.count<br \/>\n[\/cc]<br \/>\nBut this is an object which means it has properties.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nPS S:\\&gt; get-history 3 | get-member<\/p>\n<p>TypeName: Microsoft.PowerShell.Commands.HistoryInfo<\/p>\n<p>Name MemberType Definition<br \/>\n---- ---------- ----------<br \/>\nClone Method Microsoft.PowerShell.Commands.HistoryInfo Clone()<br \/>\nEquals Method bool Equals(System.Object obj)<br \/>\nGetHashCode Method int GetHashCode()<br \/>\nGetType Method type GetType()<br \/>\nToString Method string ToString()<br \/>\nCommandLine Property System.String CommandLine {get;}<br \/>\nEndExecutionTime Property System.DateTime EndExecutionTime {get;}<br \/>\nExecutionStatus Property System.Management.Automation.Runspaces.PipelineState ...<br \/>\nId Property System.Int64 Id {get;}<br \/>\nStartExecutionTime Property System.DateTime StartExecutionTime {get;}<br \/>\n[\/cc]<br \/>\nThe CommandLine property is what we are after. In my script, I get either all command history or selected items and \"export\" the commandline parameter to a text file. I made this more of a convert script by including a custom header at the beginning of the file. Take a look at the script.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nParam(<br \/>\n[Parameter(Position=0,Mandatory=$True,HelpMessage=\"Enter the filename and path for the script file\",<br \/>\nValueFromPipeline=$False)]<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[string]$Path,<\/p>\n<p>[Parameter(Mandatory=$False,ValueFromPipeline=$True)]<br \/>\n[int64[]]$ID,<\/p>\n<p>[switch]$NoClobber<br \/>\n)<\/p>\n<p>Begin {<br \/>\nSet-StrictMode -Version 2.0<\/p>\n<p>Write-Verbose \"Starting $($myInvocation.mycommand)\"<\/p>\n<p>#delete the script if it already exists<br \/>\nif ((Test-Path -Path $Path) -AND ($NoClobber))<br \/>\n{<br \/>\n$msg=\"$path already exists and NoClobber was specified.\"<br \/>\nWrite-Warning $msg<br \/>\n#bail out<br \/>\nExit<br \/>\n}<br \/>\nElseif (Test-Path -Path $path)<br \/>\n{<br \/>\nWrite-Verbose \"Removing existing version of $path\"<br \/>\nRemove-Item $Path<br \/>\n}<\/p>\n<p>#get the file name and convert the last part to upper case<br \/>\n$FileName=(Split-Path -Path $path -Leaf).ToUpper()<\/p>\n<p>#add a brief header<br \/>\n$header=@\"<br \/>\n#Requires -Version 2.0<\/p>\n<p># $Filename<br \/>\n# Generated from PowerShell History $(Get-Date)<br \/>\n# Author: $env:username<br \/>\n# $(\"-\"*80)<\/p>\n<p>\"@<\/p>\n<p>$header | Out-File -FilePath $Path -Encoding ASCII<\/p>\n<p>$history=@()<\/p>\n<p>} #close Begin<\/p>\n<p>Process {<\/p>\n<p>if ($id)<br \/>\n{<br \/>\nforeach ($i in $id)<br \/>\n{<br \/>\nWrite-Verbose \"Retrieving history item $([string]$i) $((Get-history -id $i).CommandLine)\"<br \/>\n$history+= Get-History -id $i<br \/>\n}<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nWrite-Verbose \"Retrieve All History\"<br \/>\n$history=Get-History -count $maximumhistorycount<br \/>\n}<br \/>\n} #close Process<\/p>\n<p>End {<br \/>\nWrite-Verbose \"Writing $($history.count) history commands to $path\"<\/p>\n<p>Add-Content -Path $path -Value ($history | select -expandproperty commandline ) -Encoding ASCII<br \/>\n#write the file object to the pipeline<br \/>\nWrite-Verbose \"Writing script file object to the pipeline\"<br \/>\nGet-Item -Path $path<br \/>\nWrite-Verbose \"Finished\"<br \/>\n} #close End<br \/>\n[\/cc]<br \/>\nUnlike my other posts, this is written as a script. Let's assume I have this command line history.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nPS S:\\&gt; get-history<\/p>\n<p>Id CommandLine<br \/>\n-- -----------<br \/>\n1 get-date<br \/>\n2 get-process<br \/>\n3 get-service<br \/>\n4 get-wmiobject win32_operatingsystem | select *<br \/>\n[\/cc]<br \/>\nNow to convert it to a script.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nPS S:\\&gt; .\\Convert-HistoryToScript.ps1 MyScript.ps1<\/p>\n<p>Directory: C:\\scripts<\/p>\n<p>Mode LastWriteTime Length Name<br \/>\n---- ------------- ------ ----<br \/>\n-a--- 1\/10\/2011 11:36 AM 298 MyScript.ps1<br \/>\n[\/cc]<br \/>\nThe script writes the file object to the pipeline. Here's the end result.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\n#Requires -Version 2.0<\/p>\n<p># MYSCRIPT.PS1<br \/>\n# Generated from PowerShell History 01\/10\/2011 11:36:51<br \/>\n# Author: Jeff<br \/>\n# --------------------------------------------------------------------------------<\/p>\n<p>get-date<br \/>\nget-process<br \/>\nget-service<br \/>\nget-wmiobject win32_operatingsystem | select *<br \/>\nget-history<br \/>\n[\/cc]<br \/>\nOf course, rarely do you get everything correct so you will most likely want to edit the file to clean it up. Or you can pipe in a collection of history ID numbers. Look at the script's help for a few examples. I hope you'll let me know if you find this useful.<\/p>\n<p>Download <a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/01\/Convert-HistoryToScript.txt\">Convert-HistoryToScript<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Whenever I teach or speak about PowerShell, a recurring mantra is that there is no difference between running a PowerShell script and executing commands interactively in the shell, except that it saves you typing. You can create a PowerShell script by simply copying and pasting commands from the shell into a .PS1 text file. This&#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":[4,8],"tags":[244,534,540,127],"class_list":["post-1046","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-history","tag-powershell","tag-scripting","tag-set-content"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Convert History 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\/powershell\/1046\/convert-history-to-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Convert History to Script &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Whenever I teach or speak about PowerShell, a recurring mantra is that there is no difference between running a PowerShell script and executing commands interactively in the shell, except that it saves you typing. You can create a PowerShell script by simply copying and pasting commands from the shell into a .PS1 text file. This...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2011-01-12T13:30:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-04-07T15:50:59+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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1046\\\/convert-history-to-script\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1046\\\/convert-history-to-script\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Convert History to Script\",\"datePublished\":\"2011-01-12T13:30:30+00:00\",\"dateModified\":\"2012-04-07T15:50:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1046\\\/convert-history-to-script\\\/\"},\"wordCount\":668,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"History\",\"PowerShell\",\"Scripting\",\"Set-Content\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1046\\\/convert-history-to-script\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1046\\\/convert-history-to-script\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1046\\\/convert-history-to-script\\\/\",\"name\":\"Convert History to Script &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2011-01-12T13:30:30+00:00\",\"dateModified\":\"2012-04-07T15:50:59+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1046\\\/convert-history-to-script\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1046\\\/convert-history-to-script\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1046\\\/convert-history-to-script\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Convert History 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":"Convert History 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\/powershell\/1046\/convert-history-to-script\/","og_locale":"en_US","og_type":"article","og_title":"Convert History to Script &#8226; The Lonely Administrator","og_description":"Whenever I teach or speak about PowerShell, a recurring mantra is that there is no difference between running a PowerShell script and executing commands interactively in the shell, except that it saves you typing. You can create a PowerShell script by simply copying and pasting commands from the shell into a .PS1 text file. This...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/","og_site_name":"The Lonely Administrator","article_published_time":"2011-01-12T13:30:30+00:00","article_modified_time":"2012-04-07T15:50:59+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":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Convert History to Script","datePublished":"2011-01-12T13:30:30+00:00","dateModified":"2012-04-07T15:50:59+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/"},"wordCount":668,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["History","PowerShell","Scripting","Set-Content"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/","name":"Convert History to Script &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2011-01-12T13:30:30+00:00","dateModified":"2012-04-07T15:50:59+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Convert History 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":3613,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3613\/updated-powershell-script-profiler\/","url_meta":{"origin":1046,"position":0},"title":"Updated PowerShell  Script Profiler","author":"Jeffery Hicks","date":"January 15, 2014","format":false,"excerpt":"Last year I wrote a sidebar for the Scripting Guy, Ed Wilson and an update to his PowerShell Best Practices book. I wrote a script using the new parser in PowerShell 3.0 to that would analyze a script and prepare a report showing what commands it would run, necessary parameters,\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"script-profile-report","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/script-profile-report.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/script-profile-report.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/script-profile-report.png?resize=525%2C300 1.5x"},"classes":[]},{"id":6996,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6996\/powershell-controller-scripts\/","url_meta":{"origin":1046,"position":1},"title":"PowerShell Controller Scripts","author":"Jeffery Hicks","date":"November 26, 2019","format":false,"excerpt":"When it comes to PowerShell scripting we tend to focus a lot on functions and modules. We place an emphasis on building re-usable tools. The idea is that we can then use these tools at a PowerShell prompt to achieve a given task. More than likely, these tasks are repetitive.\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-21.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-21.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-21.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-21.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":579,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/579\/powershell-picasso\/","url_meta":{"origin":1046,"position":2},"title":"PowerShell Picasso","author":"Jeffery Hicks","date":"February 23, 2010","format":false,"excerpt":"You have probably heard the story (or legend) about Pablo Picasso and his napkin drawing. A guy goes up to Picasso in a cafe and asks for an autograph or something. Picasso sketches out something in a minute or so. He turns to the guy and says, \u201cThat will be\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"powershell--picasso","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/02\/powershellpicasso_thumb.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":555,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/555\/profiling-a-script\/","url_meta":{"origin":1046,"position":3},"title":"Profiling a Script","author":"Jeffery Hicks","date":"January 14, 2010","format":false,"excerpt":"Last summer, Ed Wilson was looking for help with a small part of the book he was finishing up, Windows PowerShell 2.0 Best Practices. The topic he was working on was, \u201cHow do I know this script is safe to run?\u201d Which is a great question and one with greater\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":933,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/933\/powershell-ise-new-function\/","url_meta":{"origin":1046,"position":4},"title":"PowerShell ISE New Function","author":"Jeffery Hicks","date":"September 16, 2010","format":false,"excerpt":"Yesterday I showed how to add a menu choice to the PowerShell ISE to insert the current date and time. Today I have something even better. At least it's something I've needed for awhile. I write a lot of advanced functions in PowerShell. I'm often cutting and pasting from previous\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/09\/ise-addons.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":8724,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8724\/discovering-aliases-with-the-powershell-ast\/","url_meta":{"origin":1046,"position":5},"title":"Discovering Aliases with the PowerShell AST","author":"Jeffery Hicks","date":"December 15, 2021","format":false,"excerpt":"I've been working on a new PowerShell module that incorporates code from a few of my recent posts on converting PowerShell scripts and functions to files. I even whipped up a script, think of it as a meta-script, to create the module using the commands that I am adding to\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/12\/find-alias-string.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/12\/find-alias-string.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/12\/find-alias-string.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/12\/find-alias-string.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1046","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=1046"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1046\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}