{"id":141,"date":"2018-05-29T07:29:30","date_gmt":"2018-05-29T07:29:30","guid":{"rendered":"http:\/\/michaelschultz.net\/tech\/?p=141"},"modified":"2018-05-29T07:29:30","modified_gmt":"2018-05-29T07:29:30","slug":"powershell-script-template","status":"publish","type":"post","link":"https:\/\/michaelschultz.net\/tech\/powershell-script-template\/","title":{"rendered":"PowerShell Script Template"},"content":{"rendered":"<p>I recently went to <a href=\"https:\/\/mmsmoa.com\/\" target=\"_blank\" rel=\"noopener\">Midwest Management Summit<\/a> aka MMS (and if you are in the ConfigMan world and don&#8217;t go then you are missing out). A few of the sessions I attended were centered around scripting and how to improve things.&nbsp; One thing that was brought up a few times is having a standard on how your scripts are formatted.&nbsp; This is important as it helps when viewing the script to understand what it does and doing any work on the script.&nbsp; With that I developed the following PowerShell template I would like to share.<!--more--><\/p>\n<p>I did a few searches to get an idea of how others formatted their scripts and what to include in my template.&nbsp; What I found was that I was leaving a lot out of my previous scripts.&nbsp; Now that I have this that will no longer be the case.<\/p>\n<div class=\"codecolorer-container powershell default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"powershell codecolorer\"><span class=\"coMULTI\">&lt;#<br \/>\n.SYNOPSIS <br \/>\nScript synopsis <br \/>\n<br \/>\n.SYNTAX <br \/>\nScript syntax <br \/>\n<br \/>\n.DESCRIPTION <br \/>\nScript description <br \/>\n<br \/>\n.PARAMETER <br \/>\nParameter input descriptions and repeat this as needed for each parameter <br \/>\n<br \/>\n.INPUTS <br \/>\nInput description if used <br \/>\n<br \/>\n.OUTPUTS <br \/>\nOutput description if used <br \/>\n<br \/>\n.NOTES <br \/>\nFileName: <br \/>\nAuthor: <br \/>\nContact: <br \/>\nCreated: <br \/>\nModified: <br \/>\nVersion: <br \/>\n<br \/>\n.EXAMPLE <br \/>\nExample description and example <br \/>\n#&gt;<\/span><br \/>\n<br \/>\n<span class=\"co1\">#-----Parameters-----<\/span><br \/>\n<br \/>\n<span class=\"kw3\">Param<\/span> <span class=\"br0\">&#40;<\/span><br \/>\n<br \/>\n<span class=\"br0\">&#41;<\/span><br \/>\n<br \/>\n<span class=\"co1\">#-----Initializations and Module Imports-----<\/span><br \/>\n<br \/>\n<span class=\"co1\">#-----Variables-----<\/span><br \/>\n<br \/>\n<span class=\"co1\">#-----Functions-----<\/span><br \/>\n<br \/>\n<span class=\"co1\">#-----Execution-----<\/span><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I recently went to Midwest Management Summit aka MMS (and if you are in the ConfigMan world and don&#8217;t go then you are missing out). A few of the sessions I attended were centered around scripting and how to improve things.&nbsp; One thing that was brought up a few times is having a standard on &hellip; <a href=\"https:\/\/michaelschultz.net\/tech\/powershell-script-template\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;PowerShell Script Template&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","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":[14,13],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p98a2r-2h","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":3,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":144,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/141\/revisions\/144"}],"wp:attachment":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}