{"id":5072,"date":"2017-11-23T21:21:53","date_gmt":"2017-11-23T20:21:53","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=5072"},"modified":"2017-11-27T10:01:44","modified_gmt":"2017-11-27T09:01:44","slug":"powershell-function-pointer","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/powershell-function-pointer\/","title":{"rendered":"Powershell: Function Pointer"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_5072 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_5072')){$('.twoclick_social_bookmarks_post_5072').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Powershell%3A%20Function%20Pointer\",\"the_excerpt\":\"Hi%2C%20%0D%0A%0D%0APowershell%20provides%20also%20the%20ability%20to%20use%20function%20pointers%20such%20as%20C%20or%20C%2B%2B.%0D%0A%0D%0ADefine%20your%20functions%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/powershell-function-pointer\\\/\",\"post_id\":5072,\"post_title_referrer_track\":\"Powershell%3A+Function+Pointer\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi, <\/p>\n<p>Powershell provides also the ability to use function pointers such as C or C++.<\/p>\n<p>Define your functions<br \/>\n<!--more--><\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nfunction A(&#x5B;string]$Parameter1,&#x5B;int]$Parameter2)\r\n{\r\n\r\n   write-host &quot;Function: A&quot; &quot;Parameter 1:&quot; $Parameter1 &quot;Parameter 2:&quot; $Parameter2\r\n}\r\nfunction B(&#x5B;string]$Parameter1,&#x5B;int]$Parameter2)\r\n{\r\n   write-host &quot;Function: B&quot; &quot;Parameter 1:&quot; $Parameter1 &quot;Parameter 2:&quot; $Parameter2\r\n}\r\n<\/pre>\n<p>Assign the functions to a variable and call the function<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$pFunction=(Get-Item &quot;function:A&quot;).ScriptBlock\r\n$pFunction.Invoke(&quot;Call&quot;,2)\r\n$pFunction=(Get-Item &quot;function:B&quot;).ScriptBlock\r\n$pFunction.Invoke(&quot;Call&quot;,2)\r\n<\/pre>\n<p>That&#8217;s it \ud83d\ude42<\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, Powershell provides also the ability to use function pointers such as C or C++. Define your functions<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[344,5],"tags":[1110,1111,133,20],"class_list":["post-5072","post","type-post","status-publish","format-standard","hentry","category-powershell-scripting","category-windowsknowhow","tag-function","tag-pointer","tag-powershell","tag-windows-2"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5072","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=5072"}],"version-history":[{"count":1,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5072\/revisions"}],"predecessor-version":[{"id":5074,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5072\/revisions\/5074"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=5072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=5072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=5072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}