# Manual Testing section - put stuff here for manually testing script - typically parameters:
#=================================================================================
#=================================================================================
# Constants section - modify stuff here:
#=================================================================================
# Assign script name variable for use in event logging.
$ScriptName = "IBM.MQ.ChannelStatus.Monitor.DS.ps1"
$EventID = "17001"
#=================================================================================
# Starting Script section - All scripts get this
#=================================================================================
# Gather the start time of the script
$StartTime = Get-Date
#Set variable to be used in logging events
$whoami = whoami
# Load MOMScript API
$momapi = New-Object -comObject MOM.ScriptAPI
#Log script event that we are starting task
#$momapi.LogScriptEvent($ScriptName,$EventID,0,"`nScript is starting. `nRunning as ($whoami).")
#=================================================================================
# Begin MAIN script section
#=================================================================================
#Get the Queue Managers
$QMGRcmd = "dspmq"
$QMGRcmdOut = Invoke-Expression $QMGRcmd
FOREACH ($QMGRLine in $QMGRcmdOut)
{
$QMGRLineSplit = $QMGRLine.Split("(,)")
[string]$QueueManagerName = $QMGRLineSplit[1]
#Write-Host "Found QM: ($QueueManagerName)"
#Get the Channels from each QueueManager
$Ccmd = "cmd /c 'echo Display channel(*) | runmqsc $QueueManagerName'"
# Load PropertyBag function
$bag = $momapi.CreatePropertyBag()
#Create PropertyBags
$bag.AddValue('QueueManager',$QueueManagerName)
$bag.AddValue('ChannelName',$ChannelName)
$bag.AddValue('CStatus',$CStatus)
#Return each property bag as we create and populate it.
$bag
}
}
}
}
}
#=================================================================================
# End MAIN script section
# End of script section
#=================================================================================
#Log an event for script ending and total execution time.
$EndTime = Get-Date
$ScriptTime = ($EndTime - $StartTime).TotalSeconds
$momapi.LogScriptEvent($ScriptName,$EventID,0,"`nScript Completed. `nRunning as ($whoami). `nScript Runtime: ($ScriptTime) seconds.")
#=================================================================================
# End of script </Script></ScriptBody>
<Parameters>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="PA">
<Node ID="Scheduler"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>