PowerShell: Get Current Script Path
get the current script path
$PSCommandPath
→ the full path and filename of the running script
# get the current script fullpath Write-Host $PSCommandPath # or Write-Host $MyInvocation.MyCommand.Path
get PowerShell executable path that run the current script
# get PowerShell executable path that run the current script Write-Host $PSHOME # C:\Program Files\WindowsApps\Microsoft.PowerShell_7.4.1.0_x64__8wekyb3d8bbwe
get PowerShell version
# get PowerShell version Write-Host $PSVersionTable.PSVersion # 7.4.1 # get just the major version string. result is Int32 type Write-Host $PSVersionTable.PSVersion.Major # 7 Write-Host $PSVersionTable.PSEdition # Core Write-Host $PSVersionTable.OS # Microsoft Windows 10.0.19045 Write-Host $PSVersionTable.Platform # Win32NT
PowerShell: Profile and Script
- PowerShell: Open File by Default App
- PowerShell: Launch App, Start Process
- PowerShell: Load a Script
- PowerShell: Eval Variable, String, ScriptBlock
- PowerShell: Run PowerShell from cmd.exe via STDIN
- PowerShell: Profile (init file)
- PowerShell: Manage PowerShell Profiles
- PowerShell: Create a Script
- PowerShell: File Name Extension
- PowerShell: Get Current Script Path