PowerShell: Getting To Know PowerShell by Dan Riley
Author:Dan Riley
Language: eng
Format: azw3
Published: 2017-09-02T07:00:00+00:00
Chapter Eleven
ForEach, If/Then,
Do While Statements
Being that you understand how variables are stored in Powershell, what do you do with those variables that you have put into the program?
If/ Then
The if then statement is going to be one of the simplest forms of decision making that you can use when using Powershell. Basically, with this decision-making method, you will be constructing an if-then statement for the program to execute.
If there is something that must be compared to something else, you will then do this.
How you intend to format your statement will be based on the placement of your comparison that is inside of the parentheses before the left curly bracket is placed on a new line where you are going to add in your cmdlet or any actions that need to be performed before a new line is started. To finish off the code, you need to place off another curly bracket.
A few things to keep in mind when it comes to the if / then statements are:
Your comparison statements should have a logical response. There are only two responses that you will get and those are true or false. Basically, you must look at it as if it is a yes or no question that you are trying to answer except you are comparing two objects. If you do not get a true or false answer, then you will be creating a loop.
The code you use to execute your statement will give you a yes or no that will need to be placed inside a set of curly brackets. You have to place these brackets around the line to match them up or else your script will be more complicated than it needs to be.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12569)
Hello! Python by Anthony Briggs(9914)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9795)
The Mikado Method by Ola Ellnestam Daniel Brolund(9777)
Dependency Injection in .NET by Mark Seemann(9337)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8295)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7057)
Microservices with Go by Alexander Shuiskov(6820)
Practical Design Patterns for Java Developers by Miroslav Wengner(6738)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6678)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6413)
Angular Projects - Third Edition by Aristeidis Bampakos(6084)
The Art of Crafting User Stories by The Art of Crafting User Stories(5609)
NetSuite for Consultants - Second Edition by Peter Ries(5551)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5351)
Kotlin in Action by Dmitry Jemerov(5062)
