PowerShell function Get-ScriptDirectory

September 13, 2011 - 1 minute read -

Very often when I’m writing a script in PowerShell, I will need to obtain the directory in which that same script resides. This is sadly not completely trivial in PowerShell, but the following function achieves the desired result:


Hopefully, having created a gist for this and blogged about it, I won’t have to keep resorting to Google in future to remind me how to do this. This particular version was posted to the PowerShell Code Repository by Andy Arismendi.