{"id":3990,"date":"2014-09-05T11:55:59","date_gmt":"2014-09-05T15:55:59","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3990"},"modified":"2014-09-05T12:18:07","modified_gmt":"2014-09-05T16:18:07","slug":"friday-fun-creating-powershell-scripts-with-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/","title":{"rendered":"Friday Fun: Creating PowerShell Scripts with PowerShell"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/012914_1704_CreatingCIM1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-3650\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/012914_1704_CreatingCIM1-150x150.png\" alt=\"012914_1704_CreatingCIM1.png\" width=\"150\" height=\"150\" \/><\/a> Sometimes PowerShell really does seem like magic. Especially when you can use it to handle complicated or tedious tasks, such as creating a PowerShell script. I know many an IT Pro who want to script but without having to actually write a script. Well, I'm not sure that is realistic, but you can get pretty close. Earlier this week I showed a <a title=\"Making the Shell Work for You Revisited\" href=\"http:\/\/jdhitsolutions.com\/blog\/2014\/09\/making-the-shell-work-for-you-revisited\/\">set of commands built as proxy functions<\/a>. I made an assumption that you find something like that useful. But perhaps it still seemed like a lot of work. So I built an accelerator tool for you I call Get-CommandMetadata.<\/p>\n<pre class=\"lang:ps decode:true \">#requires -version 3.0\r\n\r\n#run this in the PowerShell ISE for best results\r\n\r\nFunction Get-CommandMetadata {\r\n\r\n&lt;#\r\n.Synopsis\r\nCreate a proxy function of a PowerShell command.\r\n.Description\r\nThis command will create a proxy version of a PowerShell cmdlet, function or alias. The intent is to simplify creating a new function from command metadata. You can give your command and opt to remove help references for the original command. \r\n\r\nIf you run this in the PowerShell ISE, code for the new function will be inserted into a new Powershell tab.\r\n.Parameter Command\r\nThe name of a PowerShell command to proxy. This can be a cmdlet, function or alias.\r\n.Parameter NewName\r\nThe name you want to use for your new command.\r\n.Parameter NoHelp\r\nRemove references to existing command help. Using this parameter will insert a comment-based help outline.\r\n.Example\r\nPS C:\\&gt; Get-CommandMetadata Get-WMIObject -nohelp -newname Get-MyOS\r\n\r\nCreate a proxy function for Get-WMIObject that will be called Get-MyOS. Help references will be replaced with a comment-help block.\r\n.Notes\r\nLast Updated: Sept. 3, 2014\r\nVersion     : 1.1\r\n\r\n.Link\r\nhttp:\/\/jdhitsolutions.com\/blog\/2014\/09\/friday-fun-creating-powershell-scripts-with-powershell\r\n\r\n#&gt;\r\n[cmdletbinding()]\r\nParam(\r\n[Parameter(Position=0,Mandatory,HelpMessage=\"Enter the name of a PowerShell command\")]\r\n[ValidateNotNullorEmpty()]\r\n[string]$Command,\r\n[string]$NewName,\r\n[switch]$NoHelp\r\n)\r\n\r\nTry {\r\n    Write-Verbose \"Getting command metadata for $command\"\r\n    $gcm = Get-Command -Name $command -ErrorAction Stop\r\n    #allow an alias or command name\r\n    if ($gcm.CommandType -eq 'Alias') {\r\n       $cmdName = $gcm.ResolvedCommandName\r\n    }\r\n    else {\r\n        $cmdName = $gcm.Name\r\n    }\r\n    Write-Verbose \"Resolved to $cmdName\"\r\n    $cmd = New-Object System.Management.Automation.CommandMetaData ($gcm)\r\n}\r\nCatch {\r\n    Write-Warning \"Failed to create command metadata for $command\"\r\n    Write-Warning $_.Exception.Message\r\n}\r\n\r\nif ($cmd) {\r\n    #create the metadata\r\n        \r\n    if ($NewName) {\r\n        $Name = $NewName\r\n    }\r\n    else {\r\n        $Name = $cmd.Name\r\n    }\r\n\r\n    if ($noHelp) {\r\n        #remove help link\r\n        $cmd.HelpUri = $Null\r\n\r\n        Write-Verbose \"Defining a new comment based help block\"\r\n        #define outline for comment based help\r\n$myHelp = @\"\r\n\r\n.Synopsis\r\nPUT SYNTAX HERE\r\n.Description\r\nPUT DESCRIPTION HERE\r\n.Notes\r\nCreated:`t$(Get-Date -format d) \r\n\r\n.Example\r\nPS C:\\&gt; $Name\r\n\r\n.Link\r\n$cmdname\r\n\r\n\"@\r\n    Write-Verbose \"Creating proxy command with help\" \r\n    $metadata = [System.Management.Automation.ProxyCommand]::Create($cmd,$myHelp)\r\n\r\n    } #nohelp\r\n    else {\r\n        Write-Verbose \"Creating proxy command\" \r\n        $metadata = [System.Management.Automation.ProxyCommand]::Create($cmd)\r\n    }\r\n\r\n   Write-Verbose \"Cleaning up parameter names\"\r\n   [regex]$rx=\"[\\s+]\\$\\{\\w+\\}[,|)]\"\r\n   $metadata = $metadata.split(\"`n\") | foreach {\r\n     If ($rx.ismatch($_)) {\r\n     #strip off { } around parameter names \r\n      $rx.Match($_).Value.Replace(\"{\",\"\").Replace(\"}\",\"\")\r\n     # \"`n\"\r\n    }\r\n    else {\r\n     #just write the line\r\n     $_\r\n     }\r\n    } #foreach\r\n\r\n#define the text for the new command\r\n    $text = @\"\r\n#requires -version $($PSVersionTable.psversion)\r\n\r\nFunction $Name {\r\n\r\n$metadata\r\n\r\n} #end function $Name\r\n\"@\r\n    if ($host.Name -match \"PowerShell ISE\") {\r\n    #open in a new ISE tab\r\n    $tab = $psise.CurrentPowerShellTab.Files.Add()\r\n\r\n    Write-Verbose \"Opening metadata in a new ISE tab\"\r\n    $tab.editor.InsertText($Text)\r\n\r\n    #jump to the top\r\n    $tab.Editor.SetCaretPosition(1,1)\r\n    }\r\n    else {\r\n      $Text\r\n    }\r\n}\r\nWrite-Verbose \"Ending $($MyInvocation.MyCommand)\"\r\n\r\n} #end function\r\n\r\nSet-Alias -Name gcmd -Value Get-CommandMetaData<\/pre>\n<p>The intent is that you can use this function to quickly create a PowerShell function based on a proxy command. My function includes parameters to give your command a new name and to strip out help references. I did this under the theory that you are building a new command on top of the underlying command and want to include your own help. If you run this function in the PowerShell ISE, it will paste your code into a new ISE tab.<\/p>\n<p>So I can run this:<\/p>\n<pre class=\"lang:ps decode:true\">get-commandmetadata Get-DnsClient -nohelp -NewName Get-MyDNSClient<\/pre>\n<p>And end up with this:<\/p>\n<pre class=\"lang:ps decode:true\">#requires -version 4.0\r\n\r\nFunction Get-MyDNSClient {\r\n\r\n[CmdletBinding(DefaultParameterSetName='ByName', PositionalBinding=$false)]\r\n param(\r\n     [Parameter(ParameterSetName='ByName', ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]\r\n     [ValidateNotNull()]\r\n     [uint32[]]\r\n  $InterfaceIndex, \r\n     [Parameter(ParameterSetName='ByName', Position=0)]\r\n     [ValidateNotNull()]\r\n     [string[]]\r\n  $InterfaceAlias, \r\n     [Parameter(ParameterSetName='ByName')]\r\n     [Alias('Suffix')]\r\n     [ValidateNotNull()]\r\n     [string[]]\r\n  $ConnectionSpecificSuffix, \r\n     [Parameter(ParameterSetName='ByName')]\r\n     [ValidateNotNull()]\r\n     [bool[]]\r\n  $RegisterThisConnectionsAddress, \r\n     [Parameter(ParameterSetName='ByName')]\r\n     [ValidateNotNull()]\r\n     [bool[]]\r\n  $UseSuffixWhenRegistering, \r\n     [Parameter(ParameterSetName='ByName')]\r\n     [Alias('Session')]\r\n     [ValidateNotNullOrEmpty()]\r\n     [Microsoft.Management.Infrastructure.CimSession[]]\r\n  $CimSession, \r\n     [Parameter(ParameterSetName='ByName')]\r\n     [int]\r\n  $ThrottleLimit, \r\n     [Parameter(ParameterSetName='ByName')]\r\n     [switch]\r\n  $AsJob) \r\n begin\r\n {\r\n     try {\r\n         $outBuffer = $null\r\n         if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))\r\n         {\r\n             $PSBoundParameters['OutBuffer'] = 1\r\n         }\r\n         $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Get-DnsClient', [System.Management.Automation.CommandTypes]::Function)\r\n         $scriptCmd = {&amp; $wrappedCmd @PSBoundParameters }\r\n         $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)\r\n         $steppablePipeline.Begin($PSCmdlet)\r\n     } catch {\r\n         throw\r\n     }\r\n }\r\n \r\n process\r\n {\r\n     try {\r\n         $steppablePipeline.Process($_)\r\n     } catch {\r\n         throw\r\n     }\r\n }\r\n \r\n end\r\n {\r\n     try {\r\n         $steppablePipeline.End()\r\n     } catch {\r\n         throw\r\n     }\r\n }\r\n &lt;#\r\n \r\n .Syntax\r\n PUT SYNTAX HERE\r\n .Description\r\n PUT DESCRIPTION HERE\r\n .Notes\r\n Created:\t9\/3\/2014 \r\n \r\n .Example\r\n PS C:\\&gt; Get-MyDNSClient\r\n \r\n .Link\r\n Get-DnsClient\r\n \r\n #&gt;\r\n \r\n\r\n} #end function Get-MyDNSClient<\/pre>\n<p>All I need to do now is modify this to meet my needs and flesh out the help. By the way, the #requires statement uses whatever version you have on the system where you run the function. That's about as easy as I can make it for right now but within a second I created 90 lines of PowerShell code with no typos!<\/p>\n<p>As always I hope some of you will give this a try and let me know what you think. Enjoy your weekend.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes PowerShell really does seem like magic. Especially when you can use it to handle complicated or tedious tasks, such as creating a PowerShell script. I know many an IT Pro who want to script but without having to actually write a script. Well, I&#8217;m not sure that is realistic, but you can get pretty&#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":"New Friday Fun: Creating #PowerShell Scripts with PowerShell http:\/\/bit.ly\/1lGwWvO","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8],"tags":[534,475,540],"class_list":["post-3990","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-powershell","tag-proxy-function","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun: Creating PowerShell Scripts with PowerShell &#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\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun: Creating PowerShell Scripts with PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Sometimes PowerShell really does seem like magic. Especially when you can use it to handle complicated or tedious tasks, such as creating a PowerShell script. I know many an IT Pro who want to script but without having to actually write a script. Well, I&#039;m not sure that is realistic, but you can get pretty...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2014-09-05T15:55:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-09-05T16:18:07+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/012914_1704_CreatingCIM1-150x150.png\" \/>\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\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun: Creating PowerShell Scripts with PowerShell\",\"datePublished\":\"2014-09-05T15:55:59+00:00\",\"dateModified\":\"2014-09-05T16:18:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/\"},\"wordCount\":286,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/012914_1704_CreatingCIM1-150x150.png\",\"keywords\":[\"PowerShell\",\"Proxy function\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/\",\"name\":\"Friday Fun: Creating PowerShell Scripts with PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/012914_1704_CreatingCIM1-150x150.png\",\"datePublished\":\"2014-09-05T15:55:59+00:00\",\"dateModified\":\"2014-09-05T16:18:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/012914_1704_CreatingCIM1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/012914_1704_CreatingCIM1.png\",\"width\":197,\"height\":239},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3990\\\/friday-fun-creating-powershell-scripts-with-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun: Creating PowerShell Scripts with PowerShell\"}]},{\"@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: Creating PowerShell Scripts with PowerShell &#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\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun: Creating PowerShell Scripts with PowerShell &#8226; The Lonely Administrator","og_description":"Sometimes PowerShell really does seem like magic. Especially when you can use it to handle complicated or tedious tasks, such as creating a PowerShell script. I know many an IT Pro who want to script but without having to actually write a script. Well, I'm not sure that is realistic, but you can get pretty...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2014-09-05T15:55:59+00:00","article_modified_time":"2014-09-05T16:18:07+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/012914_1704_CreatingCIM1-150x150.png","type":"","width":"","height":""}],"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\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun: Creating PowerShell Scripts with PowerShell","datePublished":"2014-09-05T15:55:59+00:00","dateModified":"2014-09-05T16:18:07+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/"},"wordCount":286,"commentCount":3,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/012914_1704_CreatingCIM1-150x150.png","keywords":["PowerShell","Proxy function","Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/","name":"Friday Fun: Creating PowerShell Scripts with PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/012914_1704_CreatingCIM1-150x150.png","datePublished":"2014-09-05T15:55:59+00:00","dateModified":"2014-09-05T16:18:07+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/012914_1704_CreatingCIM1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/012914_1704_CreatingCIM1.png","width":197,"height":239},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Friday Fun: Creating PowerShell Scripts with PowerShell"}]},{"@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":9057,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9057\/using-powershell-your-way\/","url_meta":{"origin":3990,"position":0},"title":"Using PowerShell Your Way","author":"Jeffery Hicks","date":"June 6, 2022","format":false,"excerpt":"I've often told people that I spend my day in a PowerShell prompt. I run almost my entire day with PowerShell. I've shared many of the tools I use daily on Github. Today, I want to share another way I have PowerShell work the way I need it, with minimal\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\/2022\/06\/dl.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/06\/dl.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/06\/dl.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/06\/dl.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":3722,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3722\/reflections-on-the-powershell-scripting-games\/","url_meta":{"origin":3990,"position":1},"title":"Reflections on the PowerShell Scripting Games","author":"Jeffery Hicks","date":"February 26, 2014","format":false,"excerpt":"During the most recent PowerShell Scripting Games, I was fortunate enough to be one of the judges. Now that the games have concluded I thought I'd share my reflections on the entries. Naturally these are merely my opinions but they are drawn from years of experience with PowerShell and almost\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"talkbubble","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":7468,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7468\/powershell-7-scripting-with-the-powershell-ise\/","url_meta":{"origin":3990,"position":2},"title":"PowerShell 7 Scripting with the PowerShell ISE","author":"Jeffery Hicks","date":"May 11, 2020","format":false,"excerpt":"By now, everyone should have gotten the memo that with the move to PowerShell 7, the PowerShell ISE should be considered deprecated. When it comes to PowerShell script and module development for PowerShell 7, the recommended tool is Visual Studio Code. It is free and offers so much more than\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\/2020\/05\/ise-ps7.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":153,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/153\/primalforms-now-available\/","url_meta":{"origin":3990,"position":3},"title":"PrimalForms now Available","author":"Jeffery Hicks","date":"November 3, 2008","format":false,"excerpt":"Even though PowerShell is by design a console based management tool, there are instances where you would like to use a GUI. PowerShell can use the Windows forms classes from the .NET Framework. However in the past creating anything other than the simplest of forms was very tedious and time\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":558,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/558\/promoting-scripting-and-powershell\/","url_meta":{"origin":3990,"position":4},"title":"Promoting Scripting and PowerShell","author":"Jeffery Hicks","date":"January 21, 2010","format":false,"excerpt":"Last week I was interviewed on the Mind of Root podcast about what administrators can do to promote PowerShell and automation in their environments. The show is now available for streaming or download. I still think your best approach is to gently let everyone know that it's not a matter\u2026","rel":"","context":"In &quot;Exchange&quot;","block_context":{"text":"Exchange","link":"https:\/\/jdhitsolutions.com\/blog\/category\/exchange\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2211,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2211\/powershell-scripting-with-validatepattern\/","url_meta":{"origin":3990,"position":5},"title":"PowerShell Scripting with [ValidatePattern]","author":"Jeffery Hicks","date":"April 19, 2012","format":false,"excerpt":"I've been writing about a number of parameters attributes you can include in your PowerShell scripting to validate parameter values. Today I want to cover using a regular expression pattern to validate a parameter value. I'm going to assume you have a rudimentary knowledge of how to use regular expressions\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":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/squarepattern-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3990","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=3990"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3990\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}