PowerShell: Get Script Path
get the current script path
# get the current script path $PSCommandPath # or $MyInvocation.MyCommand.Path
get PowerShell executable path that run the current script
# get PowerShell executable path that run the current script $PSHOME
get PowerShell version
# get just the major version string. result is Int32 type $PSVersionTable.PSVersion.Major # get PowerShell version $PSVersionTable # Name Value # ---- ----- # PSVersion 7.2.5 # PSEdition Core # GitCommitId 7.2.5 # OS Microsoft Windows 10.0.19044 # Platform Win32NT # PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} # PSRemotingProtocolVersion 2.3 # SerializationVersion 1.1.0.1 # WSManStackVersion 3.0