VMM Server BITS Configuration
http://go.microsoft.com/fwlink/?LinkId=316312
Target | Microsoft.KnowledgeServices.VMM.2012.VMMServer | ||
Parent Monitor | System.Health.ConfigurationState | ||
Category | Alert | ||
Enabled | True | ||
Alert Generate | True | ||
Alert Severity | Error | ||
Alert Priority | Normal | ||
Alert Auto Resolve | True | ||
Monitor Type | Microsoft.KnowledgeServices.Library.PowerShellMonitorEx | ||
Remotable | True | ||
Accessibility | Public | ||
Alert Message |
| ||
RunAs | Default | ||
Comment | SupportTopic=TBD;VersionNumber=1.0.0.0; |
<UnitMonitor ID="Monitor_VMMServerBITS" Comment="SupportTopic=TBD;VersionNumber=1.0.0.0;" Accessibility="Public" Enabled="true" Target="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer" ParentMonitorID="Health!System.Health.ConfigurationState" Remotable="true" Priority="Normal" TypeID="KnowledgeServicesLibrary!Microsoft.KnowledgeServices.Library.PowerShellMonitorEx" ConfirmDelivery="true">
<Category>Alert</Category>
<AlertSettings AlertMessage="MonitorMessage3c8c91c1d9ce4d08a0752b258e325def">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Property[@Name='Details']$</AlertParameter1>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<ScriptName>VMMServerBITS.ps1</ScriptName>
<Parameters>
<Parameter>
<Name>BITSTcpPort</Name>
<Value>$Target/Property[Type="MicrosoftKnowledgeServicesVMM2012Library!Microsoft.KnowledgeServices.VMM.2012.VMMServer"]/BITSTcpPort$</Value>
</Parameter>
</Parameters>
<ScriptBody>
param($BITSTcpPort)
$ErrorActionPreference = "Stop"
# Set up the arguments
$scriptargs = new-object psobject
$scriptargs | add-member NoteProperty "BITSTcpPort" $BITSTcpPort
# Set up the output
$global:scriptoutput = new-object psobject
$scriptoutput | add-member NoteProperty "HasIssue" $false
$scriptoutput | add-member NoteProperty "Details" ""
function AdvisorRule($scriptargs, $scriptoutput)
{
# Here is how you can access your script argument:
# For example: $scriptargs.Argument
# For the list of arguments that are supplied to this script, please refer
# to your rule in the Atlanta Authoring Tool
# Here is how you can add a configuration point value.
# $scriptoutput.ConfigPointA = <value>
# Be sure to add all of the ones that you specified.
$scriptoutput.HasIssue = $false;
try
{
$bitsTcpPort = $scriptargs.BITSTcpPort
$settingsFormat = "{0}\s+TCP\s+Enable" -f $bitsTcpPort
$settings = @(netsh firewall show portopening);
$matches = $settings -match $settingsFormat;
$badlist = @();
foreach ($match in $matches)
{
if (!($match -match "\s+Virtual Machine Manager Server" -or $match -match "\s+HTTPS"))
{
#Format the match string to get only the program name
# it starts like this
#443 TCP Enable Inbound Virtual Machine Manager Server
# and we only want Virtual Machine Manager Server, for example
$bad = $match;
while ($bad.Contains(" "))
{
$bad = $bad.Replace(" ", " ");
}
$badconcat = "";
$badsplit = $bad.Split(" ");
for ($i = 4; $i -lt $badsplit.Length; $i++)
{
$badconcat += $badsplit[$i] + " ";
}
$badconcat.TrimEnd(" ");
if (!$badlist.Contains($badconcat))
{
$badlist += $badconcat;
}
$scriptoutput.HasIssue = $true;
}
}
if ($scriptoutput.HasIssue)
{
$scriptoutput.Details = "BITS is configured to use port {0}, another program was found to be using the same port - " -f $bitsTcpPort
foreach ($bad in $badlist)
{
$scriptoutput.Details += $bad + ", ";
}
$scriptoutput.Details = $scriptoutput.Details.TrimEnd(", ");
}
}
catch [Exception]
{
$scriptoutput.HasIssue = $true;
$scriptoutput.Details = "Exception attempting to access BITS";
}
}
AdvisorRule $scriptargs $scriptoutput
# set the output
$mom = new-object -comobject "MOM.ScriptAPI"
$bag = $mom.CreatePropertyBag()
if ($scriptoutput.HasIssue -ne $null)
{
$bag.AddValue("HasIssue", $scriptoutput.HasIssue)
}
if ($scriptoutput.Details -ne $null)
{
$bag.AddValue("Details", $scriptoutput.Details)
}
$bag
</ScriptBody>
<SnapIns/>
<TimeoutSeconds>300</TimeoutSeconds>
<Schedule>16230</Schedule>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Boolean">Property[@Name='HasIssue']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Boolean">true</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<SuccessExpression>
<Not>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Boolean">Property[@Name='HasIssue']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Boolean">true</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</Not>
</SuccessExpression>
</Configuration>
</UnitMonitor>