Getting Started
Start as Administrator
Start PowerShell from Windows Start, and note run it as Administrator.
PowerShell in Windows10 looks something like this:
Hello World in PowerShell
Write the following command to console and press Enter:
Write-Host "Hello World!"
Moving in Tree
You can move from and to a folder with DOS-command cd. Please, note that command cd ~ moves you to your home folder. Nice ;-)
Verb-Noun -format
Commands are in form Verb-Noun. Example: If you want to know basic information of your computer write to following:
Get-ComputerInfo
You can specify what information you want to get by setting a property name:
Get-ComputerInfo -Property "OsName"
Clear-Host
Clear-Host
or shortly alias cls
clear console. Nice :-)
What PowerShell Version?
There are many versions of PowerShell. The newest is PowerShell 7.3 (in January 2023).
There are many ways to find out what version you have on your computer. One way is to use $host
-variable.
$HOST.version
PowerShell
PowerShell7
The second way is to use $PSVersionTable
-variable.
$PSVersionTable
Please note: PowerShell Core is essentially a new platform that is installed on the computer along with Windows PowerShell. It means that you cannot upgrade PowerShell 5.1 to PowerShell Core 7.1. PowerShell 7 is installed on a computer separately from Windows PowerShell 5.1. In PowerShell 7.1, the developers added maximum compatibility with Windows PowerShell. Please, read more
You can install the version 7 to your computer if you have a older version. Here is PowerShell 7 console.
Script files
You can write PowerShell script files with any text editor or tool. Save the script file with .ps1 extension!
We recommend PowerShell ISE or Visual Studio Code for writing scripts
You can select any text editor you want to, but we recommend:
1) PowerShell ISE
2) Visual Studio Code with PowerShell Extension
PowerShell execution policies
There can be restrictions to execute PowerShell on your Windows Platform.
The Default execution policy
is on Windows clients restricted. On non-Windows computers, the default execution policy is Unrestricted and cannot be changed.
You can get the current execution policy with cmdlet Get-ExecutionPolicy
. You can set the execution policy with cmdlet Set-ExecutionPolicy
. Note, that you have run it as Admiministrator.
Read more about Execution Policy