SlideShare a Scribd company logo
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!

More Related Content

PPTX
5. react native-package
PDF
While and For Loops
ODP
Virtual domains
PPTX
Intro to TDD Using PHPUnit: A FizzBuzz Kata
PPTX
Concurrency models in python
PPTX
PowerShell crash course
PPTX
Power shell basics day 7
PDF
Windows Powershell in Action 1st Edition Bruce G. Payette
5. react native-package
While and For Loops
Virtual domains
Intro to TDD Using PHPUnit: A FizzBuzz Kata
Concurrency models in python
PowerShell crash course
Power shell basics day 7
Windows Powershell in Action 1st Edition Bruce G. Payette

Similar to Power shell basics day 6 (15)

PPTX
Unix shell scripts
PDF
One man loves powershell once he failed
PPS
UNIX - Class3 - Programming Constructs
PDF
Windows Powershell in Action 1st Edition Bruce G. Payette
PDF
Windows Powershell in Action 1st Edition Bruce G. Payette
PPTX
Licão 11 decision making - statement
PDF
How To Construct IF and Else Conditional Statements
PPTX
PowerShell Zero To Hero Workshop!
PPTX
Case, Loop & Command line args un Unix
PPTX
Power shell voor developers
PPTX
Unix Shell Programming subject shell scripting ppt
PPTX
learn ps new advance for all powershell.pptx
PDF
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
PPT
Advanced Scripting - 2 (Ch-8)
PPTX
Power shell basics day 3
Unix shell scripts
One man loves powershell once he failed
UNIX - Class3 - Programming Constructs
Windows Powershell in Action 1st Edition Bruce G. Payette
Windows Powershell in Action 1st Edition Bruce G. Payette
Licão 11 decision making - statement
How To Construct IF and Else Conditional Statements
PowerShell Zero To Hero Workshop!
Case, Loop & Command line args un Unix
Power shell voor developers
Unix Shell Programming subject shell scripting ppt
learn ps new advance for all powershell.pptx
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
Advanced Scripting - 2 (Ch-8)
Power shell basics day 3
Ad

More from Ashish Raj (18)

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

Recently uploaded (20)

PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Digital Strategies for Manufacturing Companies
PPTX
L1 - Introduction to python Backend.pptx
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
System and Network Administration Chapter 2
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Nekopoi APK 2025 free lastest update
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
history of c programming in notes for students .pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Digital Strategies for Manufacturing Companies
L1 - Introduction to python Backend.pptx
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
VVF-Customer-Presentation2025-Ver1.9.pptx
Which alternative to Crystal Reports is best for small or large businesses.pdf
CHAPTER 2 - PM Management and IT Context
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Navsoft: AI-Powered Business Solutions & Custom Software Development
Upgrade and Innovation Strategies for SAP ERP Customers
Odoo Companies in India – Driving Business Transformation.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
System and Network Administration Chapter 2
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Nekopoi APK 2025 free lastest update
How to Choose the Right IT Partner for Your Business in Malaysia
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
history of c programming in notes for students .pptx

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