In PowerShell 7, there is a new set of variables all starting with “Is”. They help you understand the environment in which your script runs:

 
PS> Get-Variable -Name is*
Name                           Value
----                           -----
IsCoreCLR                      True
IsLinux                        False
IsMacOS                        False
IsWindows                      True 

In Windows PowerShell which ships with Windows, these variables do not yet exist. That’s understandable since Windows PowerShell is part of Windows and not cross-platform compatible anyway.

To run PowerShell 7 on Windows (or any of the other supported platforms), visit the releases page https://github.com/PowerShell/PowerShell/releases, scroll down to the “Assets” header and download the installation package that is most appropriate to you.

From within Windows PowerShell, simply run this one-liner:

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"

To launch PowerShell 7, run pwsh.exe.




Twitter This Tip! ReTweet this Tip!

Anonymous