Switch Statement in PowerShell


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

Sharegate: Kick-Ass Tool
Think Your SharePoint & Office 365 Are Secure ? Find Out Now!


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

KWizCom Scan