Switch Statement in PowerShell

Sathish Nadarajan
 
Solution Architect
May 14, 2016
 
Rate this article
 
Views
4272

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.

Category : PowerShell

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment