SlideShare ist ein Scribd-Unternehmen logo
1 von 7
Day 6
Conditional Execution
• If Statement
PowerShell's 'If' statement comes under the umbrella of flow
control. Once you master the basic construction then you can increase
its usefulness by appending, 'Else' and 'ElseIf' statements.
Example
Conditional Execution (Conti…)
• do while - Script block executes as long as condition value = True.
• while - Same as “do while.”
• do until – Script block executes until the condition value = True.
Conditional Execution (Conti…)
• For
The standard use of the for statement it to run the code block a
specified number of times.
Syntax:
for (initialization; condition; repeat)
{code block}
Conditional Execution (Conti…)
• ForEach
The foreach statement (also known as a foreach loop) is a language
construct for stepping through (iterating) a series of values in a
collection of items.
The simplest and most typical type of collection to traverse is an array.
Within a foreach loop it’s common to run one or more commands
against each item in an array.
Syntax:
foreach ($<item> in $<collection>)
{code block}
Conditional Execution (Conti…)
• Switch
Switch is not only a condition, but also functions like a loop.That makes
Switch one of the most powerful statements in PowerShell. Switch
works almost exactly like the Foreach loop
Thank you!

Weitere ähnliche Inhalte

Ähnlich wie Power shell basics day 6

Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)jewelyngrace
 
Introductiontoprogramminginscala
IntroductiontoprogramminginscalaIntroductiontoprogramminginscala
IntroductiontoprogramminginscalaAmuhinda Hungai
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#Rohit Rao
 
web presentation 138.pptx
web presentation 138.pptxweb presentation 138.pptx
web presentation 138.pptxAbhiYadav655132
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and loopingaprilyyy
 
Bansal presentation (1).pptx
Bansal presentation (1).pptxBansal presentation (1).pptx
Bansal presentation (1).pptxAbhiYadav655132
 
Different types of loops-Prasad.ppt
Different types of loops-Prasad.pptDifferent types of loops-Prasad.ppt
Different types of loops-Prasad.pptDxTechGaming
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJTANUJ ⠀
 
Question Pattern in Structure Programming
Question Pattern in Structure ProgrammingQuestion Pattern in Structure Programming
Question Pattern in Structure ProgrammingSuman Mia
 
Php Operators N Controllers
Php Operators N ControllersPhp Operators N Controllers
Php Operators N Controllersmussawir20
 

Ähnlich wie Power shell basics day 6 (20)

Iteration Statement in C++
Iteration Statement in C++Iteration Statement in C++
Iteration Statement in C++
 
Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)
 
Introductiontoprogramminginscala
IntroductiontoprogramminginscalaIntroductiontoprogramminginscala
Introductiontoprogramminginscala
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#
 
web presentation 138.pptx
web presentation 138.pptxweb presentation 138.pptx
web presentation 138.pptx
 
C++ chapter 4
C++ chapter 4C++ chapter 4
C++ chapter 4
 
Loops
LoopsLoops
Loops
 
Loop structures
Loop structuresLoop structures
Loop structures
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Bansal presentation (1).pptx
Bansal presentation (1).pptxBansal presentation (1).pptx
Bansal presentation (1).pptx
 
JavaScript Looping Statements
JavaScript Looping StatementsJavaScript Looping Statements
JavaScript Looping Statements
 
Different types of loops-Prasad.ppt
Different types of loops-Prasad.pptDifferent types of loops-Prasad.ppt
Different types of loops-Prasad.ppt
 
OOP java
OOP javaOOP java
OOP java
 
groovy & grails - lecture 5
groovy & grails - lecture 5groovy & grails - lecture 5
groovy & grails - lecture 5
 
The Loops
The LoopsThe Loops
The Loops
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
Question Pattern in Structure Programming
Question Pattern in Structure ProgrammingQuestion Pattern in Structure Programming
Question Pattern in Structure Programming
 
Lesson 6 php if...else...elseif statements
Lesson 6   php if...else...elseif statementsLesson 6   php if...else...elseif statements
Lesson 6 php if...else...elseif statements
 
Php Operators N Controllers
Php Operators N ControllersPhp Operators N Controllers
Php Operators N Controllers
 
Final requirement
Final requirementFinal requirement
Final requirement
 

Mehr von Ashish Raj

GitOps with Argo - Part 1.pdf
GitOps with Argo - Part 1.pdfGitOps with Argo - Part 1.pdf
GitOps with Argo - Part 1.pdfAshish Raj
 
Getting Started with IaC in Azure using ARM Template
Getting Started with IaC in Azure using ARM TemplateGetting Started with IaC in Azure using ARM Template
Getting Started with IaC in Azure using ARM TemplateAshish Raj
 
Power shell basics day 19
Power shell basics day 19Power shell basics day 19
Power shell basics day 19Ashish Raj
 
18 .NET Objects in PowerShell
18 .NET Objects in PowerShell18 .NET Objects in PowerShell
18 .NET Objects in PowerShellAshish Raj
 
Powershell basics day 17
Powershell basics day 17 Powershell basics day 17
Powershell basics day 17 Ashish Raj
 
Cloud quick start
Cloud quick startCloud quick start
Cloud quick startAshish Raj
 
Power shell basics day 16
Power shell basics day 16Power shell basics day 16
Power shell basics day 16Ashish Raj
 
PowerShell basics day 15
PowerShell basics day 15PowerShell basics day 15
PowerShell basics day 15Ashish Raj
 
Power shell basics day 14
Power shell basics day 14Power shell basics day 14
Power shell basics day 14Ashish Raj
 
Power shell basics day 13
Power shell basics day 13Power shell basics day 13
Power shell basics day 13Ashish Raj
 
PowerShell basics day 12
PowerShell basics day 12PowerShell basics day 12
PowerShell basics day 12Ashish Raj
 
Power shell basics day 11
Power shell basics day 11Power shell basics day 11
Power shell basics day 11Ashish Raj
 
Power shell basics day 9
Power shell basics day 9Power shell basics day 9
Power shell basics day 9Ashish Raj
 
Power shell basics day 8
Power shell basics day 8Power shell basics day 8
Power shell basics day 8Ashish Raj
 
Power shell basics day 7
Power shell basics day 7Power shell basics day 7
Power shell basics day 7Ashish Raj
 
Power shell basics day 5
Power shell basics day 5Power shell basics day 5
Power shell basics day 5Ashish Raj
 
Power shell basics day 4
Power shell basics day 4Power shell basics day 4
Power shell basics day 4Ashish Raj
 
Power shell basics day 3
Power shell basics day 3Power shell basics day 3
Power shell basics day 3Ashish Raj
 
Power shell basics day 2
Power shell basics day 2Power shell basics day 2
Power shell basics day 2Ashish Raj
 
Power shell basics day1
Power shell basics day1Power shell basics day1
Power shell basics day1Ashish Raj
 

Mehr von Ashish Raj (20)

GitOps with Argo - Part 1.pdf
GitOps with Argo - Part 1.pdfGitOps with Argo - Part 1.pdf
GitOps with Argo - Part 1.pdf
 
Getting Started with IaC in Azure using ARM Template
Getting Started with IaC in Azure using ARM TemplateGetting Started with IaC in Azure using ARM Template
Getting Started with IaC in Azure using ARM Template
 
Power shell basics day 19
Power shell basics day 19Power shell basics day 19
Power shell basics day 19
 
18 .NET Objects in PowerShell
18 .NET Objects in PowerShell18 .NET Objects in PowerShell
18 .NET Objects in PowerShell
 
Powershell basics day 17
Powershell basics day 17 Powershell basics day 17
Powershell basics day 17
 
Cloud quick start
Cloud quick startCloud quick start
Cloud quick start
 
Power shell basics day 16
Power shell basics day 16Power shell basics day 16
Power shell basics day 16
 
PowerShell basics day 15
PowerShell basics day 15PowerShell basics day 15
PowerShell basics day 15
 
Power shell basics day 14
Power shell basics day 14Power shell basics day 14
Power shell basics day 14
 
Power shell basics day 13
Power shell basics day 13Power shell basics day 13
Power shell basics day 13
 
PowerShell basics day 12
PowerShell basics day 12PowerShell basics day 12
PowerShell basics day 12
 
Power shell basics day 11
Power shell basics day 11Power shell basics day 11
Power shell basics day 11
 
Power shell basics day 9
Power shell basics day 9Power shell basics day 9
Power shell basics day 9
 
Power shell basics day 8
Power shell basics day 8Power shell basics day 8
Power shell basics day 8
 
Power shell basics day 7
Power shell basics day 7Power shell basics day 7
Power shell basics day 7
 
Power shell basics day 5
Power shell basics day 5Power shell basics day 5
Power shell basics day 5
 
Power shell basics day 4
Power shell basics day 4Power shell basics day 4
Power shell basics day 4
 
Power shell basics day 3
Power shell basics day 3Power shell basics day 3
Power shell basics day 3
 
Power shell basics day 2
Power shell basics day 2Power shell basics day 2
Power shell basics day 2
 
Power shell basics day1
Power shell basics day1Power shell basics day1
Power shell basics day1
 

Kürzlich hochgeladen

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 

Kürzlich hochgeladen (20)

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 

Power shell basics day 6

  • 2. Conditional Execution • If Statement PowerShell's 'If' statement comes under the umbrella of flow control. Once you master the basic construction then you can increase its usefulness by appending, 'Else' and 'ElseIf' statements. Example
  • 3. Conditional Execution (Conti…) • do while - Script block executes as long as condition value = True. • while - Same as “do while.” • do until – Script block executes until the condition value = True.
  • 4. Conditional Execution (Conti…) • For The standard use of the for statement it to run the code block a specified number of times. Syntax: for (initialization; condition; repeat) {code block}
  • 5. Conditional Execution (Conti…) • ForEach The foreach statement (also known as a foreach loop) is a language construct for stepping through (iterating) a series of values in a collection of items. The simplest and most typical type of collection to traverse is an array. Within a foreach loop it’s common to run one or more commands against each item in an array. Syntax: foreach ($<item> in $<collection>) {code block}
  • 6. Conditional Execution (Conti…) • Switch Switch is not only a condition, but also functions like a loop.That makes Switch one of the most powerful statements in PowerShell. Switch works almost exactly like the Foreach loop