Recently I am programming a NSH script that can automate all of our patch scedules (88 to be precise).
We do have 4 different environments to fullfill our DTAP strategy. (development, test, acceptance, production)
The basics ot the script is as following.
First we calculate the second tuesday which is used by Microsoft to announce its new patches.
once that is finished, we enumerate a custom property class called "CIS_MW" in which all of our maintenance windows reside as an instance.
In that instance, the maintenance window start day and start hour are defined as an integer plus the offset hours when the server needs to be analysed and offset when patches willbe prestaged which are also integers.
For everyone of the defined maintenance windows, we also create smartgroups and once they don't exist, the group will be created by this script.
These groups are used as targets for the actual patchjob.
this patchjob is looked up, and once it not exists, it will be created from a template job.
Next the advanced deployjob options are set to a template job and then copied towards the patchjob affected.
Last, the one time schedule to the patchjob is set so on the timestamp when the analysis is needed, the schedule will trigger the patchjob
This works neatly in our Development and Test environment, but in our Acceptance environment I hit some unpredicted behaviour.
#calls function to calculate second tuesday
echo "search MW instances"
for MW in `blcli_execute PropertyClass listAllInstanceNames "$MW_CUSTOM_PROP_CLASS"` ; do
blcli_execute PropertyInstance isInstanceDeprecated "$MW"
....... do some more stuff....
This peace of code looks up the "$MW_CUSTOM_PROP_CLASS" instances which all of our maintenance windows are in. and for each one do some stuff.
once I run this command without for loop. I got neat results. All of my defined instances will be printed out towards the console.
but inside this forloop, no results are retrieved and it immediately ends the for-loop without doing one thing. (the echo "$MW" codeline is never triggered.)
Can someone help me solve this issue?