Skip to main content

Introduction

Automatic Variables

The first thing to do when using PowerShell on an unknown machine is to find out which version it's running. Any version that is less than 5.1 should be upgraded. It may sound like a good idea to upgrade to the most recent version (7.3), but as of writing, most computers come preinstalled with version 5.1. Trying to run a script made in version 7.3 on a computer that has 5.1 installed could potentially cause errors, which is why this content is made with 5.1 in mind. To find out which version is currently running type and enter $PSVersionTable .

PS_Version.png

PS_Version_Result.png

The following command provides a hashtable with the version number on the first row. This particular command is known as a automatic variable and are characterized with $ in front of the variable's name. Automatic variables are predefined variables and automatically store information about the device for PowerShell use. To learn about all the types of automatic variables you can visit the Microsoft website