Avoiding Hard-Coded Paths In Powershell

Jana Sattainathan gives a few options for getting around hard-coded paths in a Powershell script:

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

dbatools 1.0 Available

Chrissy LeMaire and a cast of thousands have officially released dbatools 1.0: We are so super excited to announce that after 5 long years, dbatools 1.0 is publicly available! Our team had some lofty goals and met a vast majority of them . In the end, my personal goal for dbatools 1.0 was to have a […]

Read More

Generating Scripts from SSMS

Jeff Mlakar shows how you can use Management Studio to generate scripts for database objects: Sales.SalesOrderDetail looks like a good choice. Let’s generate a script for that table, all associated objects, and its data. The safest way to create structure including all indexes, keys, defaults, constraints, dependencies, triggers, etc. is to use SSMS Generate Scripts. I […]

Read More

Categories

February 2017
MTWTFSS
« Jan Mar »
 12345
6789101112
13141516171819
20212223242526
2728