Skip to content

Instantly share code, notes, and snippets.

@JohnL4
Created January 23, 2025 15:04
Show Gist options
  • Save JohnL4/a8002cc16f8f0c8a5d79bbfdddfd8c3b to your computer and use it in GitHub Desktop.
Save JohnL4/a8002cc16f8f0c8a5d79bbfdddfd8c3b to your computer and use it in GitHub Desktop.
Figure out the path to the currently-executing PowerShell script
<#
.SYNOPSIS
Figure out the path to the currently-executing script so we can do stuff like dot-source other PS snippets or invoke other scripts
in the same directory.
.NOTES
Can use one of:
- $MyInvocation -- Looks like this is really NOT the way to go. Seems a bit complicated to get the right info out of here.
Could be useful for a variety of info, but not the path to the current script.
- $PSCommandPath
- $PSScriptRoot
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment