PowerTip: Identify which Platform PowerShell is running on

Doctor 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

 

1 comment

Discussion is closed. Login to edit/delete existing comments.

  • John J. Kavanagh 0

    I like the isWindows, isLinux, isMacOS variables but this is a nice one.

Feedback usabilla icon