The coding blog of Alastair Smith, a software developer based in Cambridge, UK. Interested in DevOps, Azure, Kubernetes, .NET Core, and VueJS.
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.