PowerShell built in variables

Hello everybody,

today I want to write few words about PowerShell variables.

So, let's start from the simplest or with statement what is true and what is false. 

In PS it's really not philosophical question



The first one stands for false, and the second one for true. It is intended for logical operations in PS.

Very usefull is Users Home directory:


Current directory:


Information about users environment:


If you ever need to discover which version of power shell, that you execute, you can use 


Let's say that you write some kind of loop, and wonder where current item goes in, you have relieve, for this purpose you can use 


As an example consider following code, which will set location to folder temp, and with help of $_ will filter files, which have in extension letter t:

Set-Location C:\Temp

Get-ChildItem | Where-Object {$_.Name -like "*.*t*" }

Or little bit another way:

Set-Location C:\Temp

dir | Where-Object {$_.Name -like "*.*t*" }

No Comments

Add a Comment