Avoiding Hard-Coded Paths In Powershell

What if the KillerApp’s home folder suddenly moves?

Now, how do you make your app work with all its scripts without having to change code if you move it to a different folder?

You could now change the initial script that that dot-sources all the functions to alter the path and you are all set. This is still not ideal because you have to make a change when the location changed.

Click through for several options, including PSDrives and even automatically dot-sourcing Powershell scripts in the current and all child directories.

Related Posts

Cody Konior has a good post on using psake to populate the FunctionsToExport section of a module definition: The “best practice” and proper way of handling this then is to add an entry to the array in this file every time you create a new function. Manually. What a pain in the ass right? But […]

Jana Sattainathan shows how to use Powershell to look up a group of Active Directory users’ managers: Today, I received a request to find the manager for a whole bunch of users. This was a list of names (not UserId’s) in a Excel worksheet. It is not actually that complex to do it Locate the […]