The problem stemmed from the fact that I have several modes or operations that 
a script
may run against several servers. Almost all of the different operations 
required some base
set of config to be derived by executing various queries on the remote servers 
locally.

All of these jobs required a load of config to be passed into them, I wrapped 
invoke-command
in a loop that read hosts and their unique attributes from a file then spawned 
the jobs.

Some of these jobs required state information to be passed between them, but I 
could not
execute the sequence all at once unless each stage was successful on each node. 
If a node
had an issue, manual intervention would be required otherwise any node that 
proceeded would
cause the nodes not passing checks to be invalid and the clusters would be 
destroyed. So
each step has to be invoked manually.

I also write state info the successive jobs need to an xml file...

Burden came when developing the script, the script blocks for each stage reused 
code and
every change required amending each script block. So I split them into separate 
files, set them
to vars, and sourced them in one small script which then assembled them all 
including the params
and state info into one large script block that is sent to to each node, the 
single arg passed in then
invokes the required function.

Thats how I arrived at the exact example I posted, vars changed as they were 
meaningless.

If I use single quotes, how do I perform the substitution? I am also not sure 
what you mean by
decorated variables, a small nudge would be very appreciated:)

Thanks!
jlc
________________________________________
From: Michael B. Smith [[email protected]]
Sent: Friday, June 08, 2012 6:49 PM
To: NT System Admin Issues
Subject: RE: Dynamic ScriptBlock creation

There are likely 2 or 3 ways to address this (using single quotes or decorated 
variables), but I'd really like to see an real-world example, 'cuz it's not 
clear to me what you are trying to accomplish.

And, by the way, scriptblocks are always serialized as strings - so you may not 
actually be helping yourself.
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin

Reply via email to