Welcome to Bucaro TecHelp!

Bucaro TecHelp
HTTPS Encryption not required because no account numbers or
personal information is ever requested or accepted by this site

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Windows Server 2019 and PowerShell All-in-One For Dummies

PowerShell 5.1 is the current released version of Windows PowerShell and is the version that ships with Windows Server 2016 and Windows Server 2019. It is installed by default on these newer operating systems, but it's also available for install on Windows Server 2008 R2 with Service Pack1, Windows Server 2012, and Windows Server 2012 R2. The last three operating systems must have Windows Management Framework 5.1 installed to support PowerShell 5.1.

PowerShell Commands and Command Structures

When you're working with commands in PowerShell 5.1, you need to understand how to work with PowerShell variables, PowerShell comparison operators, and PowerShell loops and conditionals. You also should know how to use aliases, which are shortcuts for the more common commands.

PowerShell Variables

Creating and working with variables is simple. To create a variable, prefix the variable name with the $ and then give the variable a value:

$loc = Get-Location

To call the variable, you need only type in the $ and the variable name:


PowerShell Comparison Operators

Comparison operators typically return a true or a false. Here are the common comparison operators in use with PowerShell:

Operator Description
-gt or -ge Greater than or greater than or equal to.
-lt or -le Less than or less than or equal to.
-eq or -ne Equal to or not equal to.
-and If both inputs are true, then the output is true.
-or If one of the inputs is true, then the output is true.
-like or -notlike Uses a wildcard to match patterns.
-contains and
Checks to see if a particular value exists in an array.

PowerShell Loops and Conditionals

Conditionals are great when you need to evaluate input based on a certain set of criteria and execute a specific block of code based on that evaluation. One of the most common types is the If statement.

$car = 'Nissan'

If ($car -eq 'Ford') {
   Write-Host 'This is a Ford car.'
ElseIf ($car -eq 'Chevrolet') {
   Write-Host 'This is a Chevrolet car.'
ElseIf ($car -eq 'Nissan') {
   Write-Host 'This is a Nissan car.'
Else {
   Write-Host "Don't know what kind of car this is."

Loops are useful when you want to use the same action against multiple objects. Here are some examples of types of loops.


ForEach is used to enumerate a set of data. In the following example, the ForEach is being used to go through all the processes returned from Get-Process and it returns their names.

foreach ($proc in Get-Process){Write-Host $proc.name}


Initializes the $num variable with 1 and increments by one with each loop as long as the number is less than or equal to 10. Prints the value of $num with each loop.

$num = 1

while ($num -le 10) {
   Write-Host $num
   $num ++

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2020 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268