Get-Host or $PSVersionTable or $host cmdlets can be used to determine which version of PowerShell is installed on the system
Even if you are connected remotely to the machine running different version
it looks like $host will just show the lowest version they agreed upon for serializing.
While $PSVersionTable will show the true version
Options 1: $PSVersionTable
Version is a good choice.
If you remote to a machine running PowerShell 3, you get back 1.0, as the RemotingHost seems to be v1.
$PSVersionTable doesn't work in version 1; it was introduced in version 2.
Example
PS C:\Users> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
4 0 -1 -1
Options 2: Gethost
Options 3: Host
Version isn't a good choice. As they reflect the version of the host only, not the engine.
This seems to expected the way it was made it for.
If you remote to a machine running PowerShell 3, you get back 1.0, as the RemotingHost seems to be v1.
I wanted clarify $PSVersionTable doesn't work in version 1; it was introduced in version 2.