{"id":1369,"date":"2019-08-09T11:47:58","date_gmt":"2019-08-09T09:47:58","guid":{"rendered":"https:\/\/www.provisior.nl\/techblog\/?p=1369"},"modified":"2019-08-09T11:47:58","modified_gmt":"2019-08-09T09:47:58","slug":"get-all-available-powershell-parameters-by-script","status":"publish","type":"post","link":"https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/","title":{"rendered":"Get all available PowerShell parameters by script"},"content":{"rendered":"<p>Today I learned a nice little trick one of our MSP partners uses in their PowerShell scripts. Provisior lets you define PowerShell parameters on a global level, so you can reuse them in different PowerShell templates you define. To do this, you link the parameters to the template and define them in the &#8220;Param&#8221; section of the scripts. This involves some manual steps when configuring a PowerShell template. <\/p>\n<p>But, as I like to automate as much as possible, I was very pleased to see this partner did exactly that! Instead of linking the parameters to the template, they use this script to retrieve the parameters from the database and create PowerShell variables for them on the fly. <\/p>\n<pre><code>$SQLQuery = \"USE $SQLDatabase SELECT * FROM $PowerShellGlobalParameters\"\r\n$SQLOutput = Invoke-Sqlcmd -query $SQLQuery -ServerInstance $SQLInstance\r\n\r\nforeach ($Param in $SQLOutput){\r\n    $Name = $Param.Name\r\n    $Value = $Param.Value\r\n    New-Variable -Name $Name\r\n    Set-Variable -Name $Name -value $Value\r\n}\r\n<\/code><\/pre>\n<p>Note: you need the SQL Server PowerShell module (sqlps) loaded on the Provisior server as we use Invoke-SQLcmd. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I learned a nice little trick one of our MSP partners uses in their PowerShell scripts. Provisior lets you define PowerShell parameters on a global level, so you can reuse them in different PowerShell templates you define. To do this, you link the parameters to the template and define<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[92,97],"class_list":["post-1369","post","type-post","status-publish","format-standard","hentry","category-provisior","tag-automation","tag-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get all available PowerShell parameters by script - Provisior Tech Blog<\/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:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get all available PowerShell parameters by script - Provisior Tech Blog\" \/>\n<meta property=\"og:description\" content=\"Today I learned a nice little trick one of our MSP partners uses in their PowerShell scripts. Provisior lets you define PowerShell parameters on a global level, so you can reuse them in different PowerShell templates you define. To do this, you link the parameters to the template and define\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/\" \/>\n<meta property=\"og:site_name\" content=\"Provisior Tech Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-09T09:47:58+00:00\" \/>\n<meta name=\"author\" content=\"Stefan Krul-Donkersloot\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Stefan Krul-Donkersloot\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/2019\\\/08\\\/09\\\/get-all-available-powershell-parameters-by-script\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/2019\\\/08\\\/09\\\/get-all-available-powershell-parameters-by-script\\\/\"},\"author\":{\"name\":\"Stefan Krul-Donkersloot\",\"@id\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/#\\\/schema\\\/person\\\/a43e8689cceb46a716db67f06fee6877\"},\"headline\":\"Get all available PowerShell parameters by script\",\"datePublished\":\"2019-08-09T09:47:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/2019\\\/08\\\/09\\\/get-all-available-powershell-parameters-by-script\\\/\"},\"wordCount\":142,\"commentCount\":0,\"keywords\":[\"Automation\",\"PowerShell\"],\"articleSection\":[\"Provisior\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/2019\\\/08\\\/09\\\/get-all-available-powershell-parameters-by-script\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/2019\\\/08\\\/09\\\/get-all-available-powershell-parameters-by-script\\\/\",\"url\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/2019\\\/08\\\/09\\\/get-all-available-powershell-parameters-by-script\\\/\",\"name\":\"Get all available PowerShell parameters by script - Provisior Tech Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/#website\"},\"datePublished\":\"2019-08-09T09:47:58+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/#\\\/schema\\\/person\\\/a43e8689cceb46a716db67f06fee6877\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/2019\\\/08\\\/09\\\/get-all-available-powershell-parameters-by-script\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/2019\\\/08\\\/09\\\/get-all-available-powershell-parameters-by-script\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/2019\\\/08\\\/09\\\/get-all-available-powershell-parameters-by-script\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get all available PowerShell parameters by script\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/#website\",\"url\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/\",\"name\":\"Provisior Tech Blog\",\"description\":\"Blogs to help you get the best out of Provisior, the leading Self-service and Automation platform.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/#\\\/schema\\\/person\\\/a43e8689cceb46a716db67f06fee6877\",\"name\":\"Stefan Krul-Donkersloot\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1b2f0b419a9fee792d6a39c1a7bc92b84a848dc7859123a556058736b6481ea7?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1b2f0b419a9fee792d6a39c1a7bc92b84a848dc7859123a556058736b6481ea7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1b2f0b419a9fee792d6a39c1a7bc92b84a848dc7859123a556058736b6481ea7?s=96&d=mm&r=g\",\"caption\":\"Stefan Krul-Donkersloot\"},\"sameAs\":[\"https:\\\/\\\/www.provisior.com\"],\"url\":\"https:\\\/\\\/www.provisior.nl\\\/techblog\\\/author\\\/stefanprovisior\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get all available PowerShell parameters by script - Provisior Tech Blog","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:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/","og_locale":"en_US","og_type":"article","og_title":"Get all available PowerShell parameters by script - Provisior Tech Blog","og_description":"Today I learned a nice little trick one of our MSP partners uses in their PowerShell scripts. Provisior lets you define PowerShell parameters on a global level, so you can reuse them in different PowerShell templates you define. To do this, you link the parameters to the template and define","og_url":"https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/","og_site_name":"Provisior Tech Blog","article_published_time":"2019-08-09T09:47:58+00:00","author":"Stefan Krul-Donkersloot","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Stefan Krul-Donkersloot","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/#article","isPartOf":{"@id":"https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/"},"author":{"name":"Stefan Krul-Donkersloot","@id":"https:\/\/www.provisior.nl\/techblog\/#\/schema\/person\/a43e8689cceb46a716db67f06fee6877"},"headline":"Get all available PowerShell parameters by script","datePublished":"2019-08-09T09:47:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/"},"wordCount":142,"commentCount":0,"keywords":["Automation","PowerShell"],"articleSection":["Provisior"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/","url":"https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/","name":"Get all available PowerShell parameters by script - Provisior Tech Blog","isPartOf":{"@id":"https:\/\/www.provisior.nl\/techblog\/#website"},"datePublished":"2019-08-09T09:47:58+00:00","author":{"@id":"https:\/\/www.provisior.nl\/techblog\/#\/schema\/person\/a43e8689cceb46a716db67f06fee6877"},"breadcrumb":{"@id":"https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.provisior.nl\/techblog\/2019\/08\/09\/get-all-available-powershell-parameters-by-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.provisior.nl\/techblog\/"},{"@type":"ListItem","position":2,"name":"Get all available PowerShell parameters by script"}]},{"@type":"WebSite","@id":"https:\/\/www.provisior.nl\/techblog\/#website","url":"https:\/\/www.provisior.nl\/techblog\/","name":"Provisior Tech Blog","description":"Blogs to help you get the best out of Provisior, the leading Self-service and Automation platform.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.provisior.nl\/techblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.provisior.nl\/techblog\/#\/schema\/person\/a43e8689cceb46a716db67f06fee6877","name":"Stefan Krul-Donkersloot","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1b2f0b419a9fee792d6a39c1a7bc92b84a848dc7859123a556058736b6481ea7?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1b2f0b419a9fee792d6a39c1a7bc92b84a848dc7859123a556058736b6481ea7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1b2f0b419a9fee792d6a39c1a7bc92b84a848dc7859123a556058736b6481ea7?s=96&d=mm&r=g","caption":"Stefan Krul-Donkersloot"},"sameAs":["https:\/\/www.provisior.com"],"url":"https:\/\/www.provisior.nl\/techblog\/author\/stefanprovisior\/"}]}},"_links":{"self":[{"href":"https:\/\/www.provisior.nl\/techblog\/wp-json\/wp\/v2\/posts\/1369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.provisior.nl\/techblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.provisior.nl\/techblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.provisior.nl\/techblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.provisior.nl\/techblog\/wp-json\/wp\/v2\/comments?post=1369"}],"version-history":[{"count":2,"href":"https:\/\/www.provisior.nl\/techblog\/wp-json\/wp\/v2\/posts\/1369\/revisions"}],"predecessor-version":[{"id":1371,"href":"https:\/\/www.provisior.nl\/techblog\/wp-json\/wp\/v2\/posts\/1369\/revisions\/1371"}],"wp:attachment":[{"href":"https:\/\/www.provisior.nl\/techblog\/wp-json\/wp\/v2\/media?parent=1369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.provisior.nl\/techblog\/wp-json\/wp\/v2\/categories?post=1369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.provisior.nl\/techblog\/wp-json\/wp\/v2\/tags?post=1369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}