How to Set and Get Environment Variables in PowerShell?

get environment variable PowerShell

Recently, someone from a PowerShell community asked me about setting environment variables in PowerShell. PowerShell provides different cmdlets to do this. Let me share with you here how to set and get environment variables in PowerShell. To set an environment variable in PowerShell, you can simply use the $env variable followed by the variable name … Read more

How to Generate Random Numbers in PowerShell?

powershell random number within range

Recently, someone asked me about different methods to generate random numbers in PowerShell. I suggested different methods with examples. In this tutorial, I will show you how to generate random numbers in PowerShell with examples. To generate random numbers in PowerShell, you can use the Get-Random cmdlet. For example, to generate a single random number, … Read more

PowerShell Pipeline Variables [With Examples]

PowerShell Pipeline Variables

Recently, I gave an online session on pipeline variables for a PowerShell user group. In this tutorial, I will explain everything about PowerShell pipeline variables with examples. Pipeline variables in PowerShell, introduced with the -PipelineVariable parameter in PowerShell 7, allow you to store the output of a command within a pipeline for reuse later in the same … Read more

PowerShell Print Variable [With Examples]

powershell print variable

While working in PowerShell, there will be times when you are required to print the value of variables for debugging or logging purposes. In this tutorial, I will explain how to print variables in PowerShell using different methods and examples. To print a variable in PowerShell, you can use the Write-Output cmdlet, which sends the … Read more

How to Get Computer Name in PowerShell?

Get Computer Name in PowerShell

Recently, someone asked me to get the computer’s name in PowerShell. I tried different methods. In this tutorial, I will show you how to get the computer name in PowerShell using various cmdlets. To get the computer name in PowerShell, you can use several methods. The simplest is using the environment variable $env:COMPUTERNAME. Alternatively, you … Read more

How to Restart a Computer Using PowerShell?

I will show you here how to restart a computer using PowerShell. We will see different cmdlets with examples. To restart a computer using PowerShell, you can use the Restart-Computer cmdlet. For a local restart, simply run Restart-Computer in an elevated PowerShell session. To restart a remote computer, use Restart-Computer -ComputerName “RemoteComputerName” and provide credentials … Read more

How to Change Directory in PowerShell?

Do you need to know how to change the directory in PowerShell? In this tutorial, I will show you different methods to change the directory in PowerShell. To change directories in PowerShell, you can use the cd command followed by the path of the directory you wish to navigate to. For example, to switch to … Read more

How to Add Comments in PowerShell?

Add Comments in PowerShell

If you want to write industry-standard PowerShell scripts, you should know how to add comments in PowerShell. Let me explain this in detail with examples. To add comments in PowerShell, you can use the hash symbol (#). Any text following the # on the same line will be treated as a comment and ignored during execution. For example: … Read more

PowerShell Filter Operators [With Examples]

PowerShell Filter Operators

If you want to write good quality PowerShell script, then you should know how to use PowerShell filter operators. In this tutorial, I will show you how to use filter operators in PowerShell with examples. PowerShell Filter Operators PowerShell filter operators are used to compare values or filter elements of a collection against an input … Read more

PowerShell Arithmetic Operators [With Examples]

PowerShell Arithmetic Operators

Recently, I worked on a PowerShell script that involved some addition and subtraction operations. I tried different examples. In this tutorial, I will show you how to use PowerShell arithmetic operators with examples. PowerShell provides a range of arithmetic operators to perform basic calculations. These operators include addition (+), subtraction (-), multiplication (*), division (/), … Read more

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.