Mindblown: a blog about philosophy.
-
Syntax
The following block describes a syntax for a function: The above syntax includes the following terms:
-
PowerShell Functions
When we need to use the same code in more than one script, then we use a PowerShell function. A function is a list of PowerShell statements whose name is assigned by the user. When we execute a function, we type the name of a function. Like the cmdlets, functions can also have parameters. The function parameters can…
-
PowerShell String
The PowerShell string is simply an object with a System.String type. It is a datatype that denotes the sequence of characters, either as a literal constant or some kind of variable. A String can be defined in PowerShell by using the single or double-quotes. Both the strings are created of the same System.String object type. Examples: Example1: This example describes how to…
-
Continue and Break Statement
Continue Statement The Continue statement is used in PowerShell to return the flow of the program to the top of an innermost loop. This statement is controlled by the for, Foreach and while loop. When this statement is executed in a loop, the execution of code inside that loop following the continue statement will be skipped, and the next iteration of…
-
While loop
In a PowerShell, the While loop is also known as a While statement. It is an entry-controlled loop. This loop executes the statements in a code of block when a specific condition evaluates to True. This loop is easier to construct than for statement because the syntax of this loop is less complicated. Syntax of While loop When we execute a while…
-
ForEach loop
The Foreach loop is also known as a Foreach statement in PowerShell. The Foreach is a keyword which is used for looping over an array or a collection of objects, strings, numbers, etc. Mainly, this loop is used in those situations where we need to work with one object at a time. Syntax The following block shows the syntax of Foreach loop: In…
-
For Loop
The For loop is also known as a ‘For‘ statement in a PowerShell. This loop executes the statements in a code of block when a specific condition evaluates to True. This loop is mostly used to retrieve the values of an array. Syntax of For loop In this Syntax, the Initialization placeholder is used to create and initialize the…
-
Do-While Loop
When we need to run a loop at least once, then we use the Do-while loop in a PowerShell. The Do-While loop is a looping structure in which a condition is evaluated after executing the statements. This loop is also known as the exit-controlled loop. The do-while loop is the same as while loop, but the condition in a do-while loop…
-
Switch Statement
When you need to check the multiple conditions in PowerShell, we must use the Switch statement. This statement in PowerShell is equivalent to the series of ‘If‘ statements, but it is simple to use. This statement lists each condition and the code of block associated with each condition. If a condition is ‘True‘, then the…
-
Else-if Statement
This type of statement is also known as ‘Else-if‘ ladder. It is useful when you want to check more than one condition within a code. If the condition of any ‘If‘ block is True, then the statements associated with that block are executed. If none of the conditions are True, then the statements inside default else block are executed.…
Got any book recommendations?