{"id":179,"date":"2014-09-01T18:57:41","date_gmt":"2014-09-01T22:57:41","guid":{"rendered":"http:\/\/blog.metcorp.org\/?p=179"},"modified":"2014-09-08T20:19:48","modified_gmt":"2014-09-09T00:19:48","slug":"powershell-parameters","status":"publish","type":"post","link":"https:\/\/adsecurity.org\/?p=179","title":{"rendered":"PowerShell Parameters"},"content":{"rendered":"<p>One of the most useful features in Powershell is Parameters.<br \/>\nMicrosoft has some excellent <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/dd347600.aspx\">documentation on Powershell Parameters<\/a><\/p>\n<p>Some of my favorites:<\/p>\n<p><span style=\"text-decoration: underline;\">Default Parameter<\/span><\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">[Switch]$Enabled = $True<\/span><\/pre>\n<\/blockquote>\n<p><span style=\"text-decoration: underline;\">Mandatory Parameter<\/span><\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">[parameter(Mandatory=$true)]<\/span>\r\n<span style=\"color: #0000ff;\">[String]$Name<\/span><\/pre>\n<\/blockquote>\n<p><span style=\"text-decoration: underline;\">Validate Parameter Options in \u00a0a set<\/span><\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">[ValidateSet(\"TCP\", \"UDP\")]<\/span>\r\n<span style=\"color: #0000ff;\">[string]$NewPortType<\/span><\/pre>\n<\/blockquote>\n<p><span style=\"text-decoration: underline;\">Validate Parameter Options in a range (case INsensitive)<br \/>\n<\/span><\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">[ValidateRange(1,65535)]<\/span>\r\n<span style=\"color: #0000ff;\">[string]$NewPortNumber<\/span><\/pre>\n<\/blockquote>\n<p><span style=\"color: #0000ff;\"><span style=\"text-decoration: underline;\"><span style=\"color: #000000; text-decoration: underline;\">Add Parameter Aliases<\/span><\/span><br \/>\n<\/span><\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">[alias(\"PortScope\",\"Scope\")]<\/span>\r\n<span style=\"color: #0000ff;\">[string] $NewPortScope<\/span><\/pre>\n<\/blockquote>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the most useful features in Powershell is Parameters. Microsoft has some excellent documentation on Powershell Parameters Some of my favorites: Default Parameter [Switch]$Enabled = $True Mandatory Parameter [parameter(Mandatory=$true)] [String]$Name Validate Parameter Options in \u00a0a set [ValidateSet(&#8220;TCP&#8221;, &#8220;UDP&#8221;)] [string]$NewPortType Validate Parameter Options in a range (case INsensitive) [ValidateRange(1,65535)] [string]$NewPortNumber Add Parameter Aliases [alias(&#8220;PortScope&#8221;,&#8221;Scope&#8221;)] [string] &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/adsecurity.org\/?p=179\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,2],"tags":[64,575],"class_list":["post-179","post","type-post","status-publish","format-standard","hentry","category-powershell","category-technical-reference","tag-parameters","tag-powershell","item-wrap"],"_links":{"self":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=179"}],"version-history":[{"count":3,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/179\/revisions"}],"predecessor-version":[{"id":182,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/179\/revisions\/182"}],"wp:attachment":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}