PowerTip: Identify which Platform PowerShell is running on

Doctor Scripto

Dr Scripto

Summary: Using $PSVersionTable to identify if you are on Windows or Unix

A picture containing scissors  Description automatically generated

Hey, Doctor Scripto! I’m working on my PowerShell scripts and I need to be able to identify if I’m working on Windows or Linux. How can I do this easily?

No problem at all and glad to help. Just examine the $PSVersionTable property called Platform. It will contain one either ‘Unix’,’Win32NT’ on PowerShell Core. In the case of Windows PowerShell it will not exist.

$PSVersionTable.Platform

PowerShell, Doctor Scripto, PowerTip, Sean Kearney

 

Doctor Scripto
Dr Scripto

Scripter, PowerShell, vbScript, BAT, CMD

Follow Dr Scripto   

1 comment

Leave a comment