Switch Statement in PowerShell


Sathish Nadarajan
SharePoint MVP
Published On :   14 May 2016
Visit Count
Today :  2    Total :   2246
Plan, Migrate, Secure, Report
SharePoint & Office 365 Tool. Simple & Easy to Use. 15-Day Trial!

SharePoint Office 365 Tool
Simple & Powerful Tool for Migration, Security & Reporting. Free Trial


In the recent days, being a SharePoint developer, most of the times, we are working on the Powershell and its been essential to have all the syntax of PowerShell as that of C#.

Recently, I was about to write a switch statement and thought of sharing here.

They are very straight forward. But even, then I just wanted to make sure that we have all the syntax handy. (For future reference J )

 function ExecuteFunctions($input1)
 {
     switch($input1)
     { 
         1
         {
             # Do the action
             #
         }
         2
         {
             # Do the action
             
         }
          
         default
         {
             break
         }
     }
 }
 

Happy Coding,

Sathish Nadarajan.

SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Categories

Migratiin Tools for SharePoint