{"id":78719,"date":"2026-06-27T18:05:41","date_gmt":"2026-06-27T18:05:41","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=78719"},"modified":"2026-06-27T18:05:41","modified_gmt":"2026-06-27T18:05:41","slug":"cmdletbinding","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=78719","title":{"rendered":"CmdletBinding"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Ref: AI Tools\/ChatGPT<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>[CmdletBinding()]<\/code> turns a normal PowerShell function into an <strong>advanced function<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That means the function behaves more like a real PowerShell cmdlet.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Basic example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Normal function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function Install-Office {\n    param(\n        &#91;string]$Version\n    )\n\n    Write-Host \"Installing Office $Version\"\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Advanced function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function Install-Office {\n    &#91;CmdletBinding()]\n    param(\n        &#91;string]$Version\n    )\n\n    Write-Host \"Installing Office $Version\"\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">What <code>[CmdletBinding()]<\/code> does<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It gives your function cmdlet-style behavior, such as:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>Meaning<\/th><\/tr><\/thead><tbody><tr><td>Common parameters<\/td><td>Allows parameters like <code>-Verbose<\/code>, <code>-Debug<\/code>, <code>-ErrorAction<\/code><\/td><\/tr><tr><td>Better parameter handling<\/td><td>Works better with <code>[Parameter()]<\/code>, mandatory parameters, parameter sets<\/td><\/tr><tr><td>Pipeline support<\/td><td>Works well with <code>ValueFromPipeline<\/code> and <code>process {}<\/code><\/td><\/tr><tr><td>Professional structure<\/td><td>Makes custom functions look and behave more like built-in cmdlets<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Example with <code>-Verbose<\/code><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>function Test-LabFunction {\n    &#91;CmdletBinding()]\n    param(\n        &#91;string]$Name\n    )\n\n    Write-Verbose \"The function received the name $Name\"\n    Write-Host \"Hello $Name\"\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Run normally:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Test-LabFunction -Name \"Sayed\"\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello Sayed\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Run with <code>-Verbose<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Test-LabFunction -Name \"Sayed\" -Verbose\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>VERBOSE: The function received the name Sayed\nHello Sayed\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Without <code>[CmdletBinding()]<\/code>, <code>-Verbose<\/code> would not work the same way.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example with mandatory parameter<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>function Install-Office {\n    &#91;CmdletBinding()]\n    param(\n        &#91;Parameter(Mandatory)]\n        &#91;ValidateSet(\"2013\",\"2016\")]\n        &#91;string]$Version\n    )\n\n    Write-Host \"I installed Office $Version.\"\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now if the user runs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Install-Office\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">PowerShell asks for the missing mandatory value:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cmdlet Install-Office at command pipeline position 1\nSupply values for the following parameters:\nVersion:\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Simple explanation for students<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><code>[CmdletBinding()]<\/code> upgrades a function into an advanced PowerShell function. It allows the function to support cmdlet-like features such as <code>-Verbose<\/code>, better parameter behavior, validation, parameter sets, and pipeline-friendly design.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Very short version<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;CmdletBinding()]\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">means:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u201cTreat this function like a professional PowerShell cmdlet.\u201d<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Ref: AI Tools\/ChatGPT [CmdletBinding()] turns a normal PowerShell function into an advanced function. That means the function behaves more like a real PowerShell cmdlet. Basic example Normal function: Advanced function: What [CmdletBinding()] does It gives your function cmdlet-style behavior, such as: Feature Meaning Common parameters Allows parameters like -Verbose, -Debug, -ErrorAction Better parameter handling Works &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=78719\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1981],"tags":[],"class_list":["post-78719","post","type-post","status-publish","format-standard","hentry","category-power-shell","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":71266,"url":"http:\/\/bangla.sitestree.com\/?p=71266","url_meta":{"origin":78719,"position":0},"title":"Difference: Auto-Regressive and Auto Correlation.","author":"Sayed","date":"September 27, 2021","format":false,"excerpt":"If you can, answer the question below: Write your answer in the comment box. Difference: Auto-Regressive and Auto Correlation.","rel":"","context":"In &quot;Matrix and Signal Processing&quot;","block_context":{"text":"Matrix and Signal Processing","link":"http:\/\/bangla.sitestree.com\/?cat=1944"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":321,"url":"http:\/\/bangla.sitestree.com\/?p=321","url_meta":{"origin":78719,"position":1},"title":"Word 2010 Essential &#8211; 73. Auto Correct and Auto Formatting","author":"Author-Check- Article-or-Video","date":"April 6, 2013","format":false,"excerpt":"","rel":"","context":"In &quot;Complete Courses&quot;","block_context":{"text":"Complete Courses","link":"http:\/\/bangla.sitestree.com\/?cat=29"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":71272,"url":"http:\/\/bangla.sitestree.com\/?p=71272","url_meta":{"origin":78719,"position":2},"title":"Give some examples of Auto-Regressive Processes?","author":"Sayed","date":"September 27, 2021","format":false,"excerpt":"If you can, answer the question below: Write your answer in the comment box. Give some examples of Auto-Regressive Processes?","rel":"","context":"In &quot;Matrix and Signal Processing&quot;","block_context":{"text":"Matrix and Signal Processing","link":"http:\/\/bangla.sitestree.com\/?cat=1944"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":71270,"url":"http:\/\/bangla.sitestree.com\/?p=71270","url_meta":{"origin":78719,"position":3},"title":"What is the relation between Auto-Regressive Process and Toeplitz systems?","author":"Sayed","date":"September 27, 2021","format":false,"excerpt":"If you can, answer the question below: Write your answer in the comment box. What is the relation between Auto-Regressive Process and Toeplitz systems?","rel":"","context":"In &quot;Matrix and Signal Processing&quot;","block_context":{"text":"Matrix and Signal Processing","link":"http:\/\/bangla.sitestree.com\/?cat=1944"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":71274,"url":"http:\/\/bangla.sitestree.com\/?p=71274","url_meta":{"origin":78719,"position":4},"title":"Can we say that voice and video signals, sinewaves-plus-noise, signals in control systems and signals induced by earthquakes are some examples of Auto-Regressive Processes?","author":"Sayed","date":"September 27, 2021","format":false,"excerpt":"If you can, answer the question below: Write your answer in the comment box. Can we say that voice and video signals, sinewaves-plus-noise, signals in control systems and signals induced by earthquakes are some examples of Auto-Regressive Processes?","rel":"","context":"In &quot;Matrix and Signal Processing&quot;","block_context":{"text":"Matrix and Signal Processing","link":"http:\/\/bangla.sitestree.com\/?cat=1944"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1155,"url":"http:\/\/bangla.sitestree.com\/?p=1155","url_meta":{"origin":78719,"position":5},"title":"Excel 2013 Tips,Tricks and Shortcuts (Bengali) &#8211; 22. Auto fill in Excel (\u098f\u0995\u09cd\u09b8\u09c7\u09b2\u09c7\u09b0 \u09e8\u09e6\u09e7\u09e9 \u099f\u09bf\u09aa\u09b8, \u099f\u09cd\u09b0\u09bf\u0995\u09b8 \u098f\u09ac\u0982 \u09b6\u09b0\u09cd\u099f\u0995\u09be\u099f (\u09ac\u09be\u0982\u09b2\u09be) &#8211; \u09e8\u09e8. \u098f\u0995\u09cd\u09b8\u09c7\u09b2 \u098f \u0985\u099f\u09cb \u09ab\u09bf\u09b2)","author":"Author-Check- Article-or-Video","date":"April 18, 2013","format":false,"excerpt":"","rel":"","context":"In &quot;Complete Courses&quot;","block_context":{"text":"Complete Courses","link":"http:\/\/bangla.sitestree.com\/?cat=29"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/78719","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=78719"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/78719\/revisions"}],"predecessor-version":[{"id":78720,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/78719\/revisions\/78720"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=78719"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=78719"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=78719"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}