Monday, February 13, 2012

Creating a library of scripts

I found this nice thread for invoking powershell scripts from another.

Since there is a script I keep calling for pulling the current data.

This came in useful. What I am doing is passing my other scripts a list of servers.

This list of servers keeps changing constantly and is updated into a SQL table. So every time I wanted a current list of servers I had to connect to SQL and pull the list manually

and present that to the script I wanted to run on that list.

So I found a good script which would allow me to query the table within power shell and pass that list to any other script.

I just add the following lines to the script I want to run on all the servers.

$ScriptDir = split-path -parent $MyInvocation.MyCommand.Path
. "$ScriptDir\Lib.ps1"

Where lib.ps1 is my script querying the database.

No comments:

Post a Comment