CodeBork | Tales from the Codeface

The coding blog of Alastair Smith, a software developer based in Cambridge, UK. Interested in DevOps, Azure, Kubernetes, .NET Core, and VueJS.


Project maintained by Hosted on GitHub Pages — Theme by mattgraham

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:

[gist:1215274]

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.