Friday, September 24, 2010

Ops Mgr Command Line Switches

If you ever wanted to start Ops Mgr from the command line, or force it into certain views when it comes up, here's the ticket:


That plays out as:

Microsoft.MOM.UI.Console.exe {/option[:value]}

/? - show this help window
/ClearCache - clear the UI cache
/Server: - connect to the specified server
/Viewname: - display a view
/Taskname: - run a task
/TaskTarget: - use in conjunction with /task
/ManagementPack: - use in conjunction with /taskname and /viewnane options

Thursday, September 23, 2010

Ops Mgr's Application View Schema

It's not news to anyone trying to build Ops Mgr Management Packs that the Authoring Console does not expose all of the options supported and that often you have to edit the XML by hand.

That task gets much easier if you have/understand the schema you're working with. Here's one that I've been working with - the Application View xsd. Enjoy!

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeSpanCriteriaType">
<xsd:simpleContent>
<xsd:extension base="xsd:unsignedInt">
<xsd:attribute name="Unit" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Second"/>
<xsd:enumeration value="Minute"/>
<xsd:enumeration value="Hour"/>
<xsd:enumeration value="Day"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeRangeCriteriaType">
<xsd:choice>
<xsd:element name="WithinLast" type="TimeSpanCriteriaType"/>
<xsd:element name="Range">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="After" type="xsd:dateTime" minOccurs="0"/>
<xsd:element name="Before" type="xsd:dateTime" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="DomainComputerCriteriaType">
<xsd:sequence>
<xsd:element name="Domain" type="xsd:string" minOccurs="0"/>
<xsd:element name="Computer" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SLECriteriaType">
<xsd:annotation>
<xsd:documentation>a single Service Level Exception criteria</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Duration" type="TimeSpanCriteriaType"/>
<xsd:element name="ResolutionState" type="xsd:unsignedByte"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="GUIDCriteriaType">
<xsd:annotation>
<xsd:documentation>The representation of a GUID, generally the id of an element.</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:pattern value="\{[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="DiagramViewPresentationCriteriaType">
<xsd:sequence>
<xsd:element name="DiagramViewDisplay" type="DiagramViewDisplayType" minOccurs="0"/>
<xsd:element name="DiagramMonitoringClass" type="DiagramMonitoringClassType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="DiagramMonitoringRelationshipClass" type="DiagramMonitoringRelationshipClassType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="DiagramViewDisplayType">
<xsd:annotation>
<xsd:documentation>Diagram view display</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="BackgroundImageHotSpot" type="BackgroundImageHotSpotType" default="TopRight" minOccurs="0"/>
<xsd:element name="ContainmentStyle" type="ContainmentStyleType" default="NonBox" minOccurs="0"/>
<xsd:element name="LayoutDirection" type="LayoutDirectionType" default="NorthSouth" minOccurs="0"/>
<xsd:element name="NodesPerRow" type="xsd:int" default="2" minOccurs="0"/>
<xsd:element name="BoxBackgroundImageHotSpot" type="BackgroundImageHotSpotType" default="TopRight" minOccurs="0"/>
<xsd:element name="LevelsToShow" type="xsd:int" default="2" minOccurs="0"/>
<xsd:element name="ContainmentLine" type="LineType" minOccurs="0"/>
<xsd:element name="NonContainmentLine" type="LineType" minOccurs="0"/>
<xsd:element name="MaxNumChild" type="xsd:int" minOccurs="0" default="8"/>
<xsd:element name="MinBucketSize" type="xsd:int" minOccurs="0" default="5"/>
<xsd:element name="VirtualGroupThreshold" type="xsd:int" minOccurs="0" default="8"/>
</xsd:sequence>
<xsd:attribute name="ShowVirtualGroup" type="xsd:boolean" use="optional" default="true"/>
</xsd:complexType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="DiagramMonitoringClassType">
<xsd:annotation>
<xsd:documentation>Diagram class</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="ID" type="xsd:string">
<xsd:annotation>
<xsd:documentation>ManagementPack.MonitoringClass decorated id</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="ContainmentStyle" type="ContainmentStyleType" default="NonBox" minOccurs="0"/>
<xsd:element name="LayoutDirection" type="LayoutDirectionType" default="NorthSouth" minOccurs="0"/>
<xsd:element name="NodesPerRow" type="xsd:int" default="3" minOccurs="0"/>
<xsd:element name="BoxBackgroundImageHotSpot" type="BackgroundImageHotSpotType" default="TopRight" minOccurs="0"/>
<xsd:element name="LevelsToShow" type="xsd:int" default="-1" minOccurs="0">
<xsd:annotation>
<xsd:documentation>-1 = Inherit from parent, 0 = Collapsed </xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="Layer" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Assigned layer</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="Tooltips" type="TooltipType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Tooltip properties</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="Annotations" type="AnnotationsType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Annotations</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="VirtualGroup" type="VirtualGroupType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Virtual group properties</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="IsExcluded" type="xsd:boolean" use="optional" default="false"/>
</xsd:complexType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ContainmentStyleType">
<xsd:annotation>
<xsd:documentation>Diagram style type</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Box"/>
<xsd:enumeration value="NonBox"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="LayoutDirectionType">
<xsd:annotation>
<xsd:documentation>Placement style type</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="NorthSouth"/>
<xsd:enumeration value="SouthNorth"/>
<xsd:enumeration value="WestEast"/>
<xsd:enumeration value="EastWest"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="BorderStyleType">
<xsd:annotation>
<xsd:documentation>Border style type</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Solid"/>
<xsd:enumeration value="Dot"/>
<xsd:enumeration value="Dash"/>
<xsd:enumeration value="DashDot"/>
<xsd:enumeration value="DashDotDot"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="BoxBorderWidthType">
<xsd:annotation>
<xsd:documentation>Border width type</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:double">
<xsd:pattern value="[1-5]"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ColorType">
<xsd:annotation>
<xsd:documentation>Box header color</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="Red" type="xsd:int" default="0"/>
<xsd:attribute name="Green" type="xsd:int" default="0"/>
<xsd:attribute name="Blue" type="xsd:int" default="0"/>
</xsd:complexType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="BackgroundImageHotSpotType">
<xsd:annotation>
<xsd:documentation>Box background image hotspot</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="None"/>
<xsd:enumeration value="Middle"/>
<xsd:enumeration value="TopRight"/>
<xsd:enumeration value="BottomRight"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TooltipType">
<xsd:annotation>
<xsd:documentation>Tooltips</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Property" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AnnotationsType">
<xsd:annotation>
<xsd:documentation>Annotations</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Annotation" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Property" type="xsd:string"/>
<xsd:element name="Hotspot" type="AnnotationHotSpotType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AnnotationHotSpotType">
<xsd:annotation>
<xsd:documentation>Annotation hot spot</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="FirstHotSpot"/>
<xsd:enumeration value="SecondHotSpot"/>
<xsd:enumeration value="ThirdHotSpot"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="VirtualGroupType">
<xsd:annotation>
<xsd:documentation>Virtual groups</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="VirtualGroupBy" type="VirtualGroupByType" default="ByType"/>
<xsd:element name="VirtualGroupHealthRollup" type="VirtualGroupHealthRollupType" default="WorstOf"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="VirtualGroupHealthRollupType">
<xsd:annotation>
<xsd:documentation>Virtual group health rollup</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="BestOf"/>
<xsd:enumeration value="WorstOf"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="VirtualGroupByType">
<xsd:annotation>
<xsd:documentation>Virtual group type</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="ByType"/>
<xsd:enumeration value="ByHealth"/>
<xsd:enumeration value="ByTypeAndHealth"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="DiagramMonitoringRelationshipClassType">
<xsd:annotation>
<xsd:documentation>Diagram relationship class</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="ID" type="xsd:string"/>
<xsd:element name="Tooltips" type="TooltipType" minOccurs="0"/>
<xsd:element name="Line" type="LineType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="IsExcluded" type="xsd:boolean" use="optional" default="false"/>
</xsd:complexType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="LineType">
<xsd:annotation>
<xsd:documentation>Line type</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Color" type="ColorType" minOccurs="0"/>
<xsd:element name="LineWidth" type="LineWidthType" default="1" minOccurs="0"/>
<xsd:element name="SourceArrow" type="ArrowType" minOccurs="0"/>
<xsd:element name="TargetArrow" type="ArrowType" minOccurs="0"/>
<xsd:element name="LineStyle" type="BorderStyleType" default="Solid" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="LineWidthType">
<xsd:annotation>
<xsd:documentation>Line width type</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:double">
<xsd:pattern value="[1-5]"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ArrowType">
<xsd:annotation>
<xsd:documentation>Arrow type</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="ArrowStyle" type="ArrowStyleType" default="Flat" minOccurs="0"/>
<xsd:element name="ArrowWidth" type="ArrowSizeType" default="5" minOccurs="0"/>
<xsd:element name="ArrowHeight" type="ArrowSizeType" default="5" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="IsFilled" type="xsd:boolean" default="true"/>
</xsd:complexType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ArrowStyleType">
<xsd:annotation>
<xsd:documentation>Arrow styles</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Flat"/>
<xsd:enumeration value="NoAnchor"/>
<xsd:enumeration value="AnchorMask"/>
<xsd:enumeration value="ArrowAnchor"/>
<xsd:enumeration value="DiamondAnchor"/>
<xsd:enumeration value="Round"/>
<xsd:enumeration value="RoundAnchor"/>
<xsd:enumeration value="Square"/>
<xsd:enumeration value="SquareAnchor"/>
<xsd:enumeration value="Triangle"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ArrowSizeType">
<xsd:annotation>
<xsd:documentation>Arrow size type type</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:int">
<xsd:pattern value="[1-9]"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ColumnInfoType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>
<xsd:element name="Id" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="Index" type="xsd:integer" use="required"/>
<xsd:attribute name="SortIndex" type="xsd:integer" use="required"/>
<xsd:attribute name="Width" type="xsd:integer" use="required"/>
<xsd:attribute name="Grouped" type="xsd:boolean" use="required"/>
<xsd:attribute name="Sorted" type="xsd:boolean" use="required"/>
<xsd:attribute name="IsSortable" type="xsd:boolean" use="required"/>
<xsd:attribute name="Visible" type="xsd:boolean" use="required"/>
<xsd:attribute name="SortOrder" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:element name="Configuration">
<xsd:complexType>
<xsd:sequence>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Criteria" type="xsd:string" minOccurs="0"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Presentation" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="DiagramViewCriteria" type="DiagramViewPresentationCriteriaType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Target" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

Tuesday, September 21, 2010

VBScript: Start a Windows Explorer to a specific directory

WshShell.Run "explorer.exe /e," & Directory

VBScript: Filesystem stuff

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists(ORIGINAL) then
Const FOF_CREATEPROGRESSDLG = &H0&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(TARGET)
objFolder.MoveHere ORIGINAL, FOF_CREATEPROGRESSDLG
If objFSO.FolderExists(ORIGINAL) then
objFolder.MoveHere ORIGINAL, FOF_CREATEPROGRESSDLG
end if

Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")

if FSO.FileExists(ORIGINAL & "\config\Discovery.xml") then
FSO.CopyFile ORIGINAL & "\config\Discovery.xml", InstallLocation & "\config\"
End If
end if

VBScript: Getting User's Home Directory

Set colProcessEnvVars = WshShell.Environment("Process")
HomeDir = colProcessEnvVars("HOMEDRIVE") & colProcessEnvVars("HOMEPATH")

VBScript: Check the bit-ness of the OS

Set WshShell = WScript.CreateObject("WScript.Shell")
Set colProcessEnvVars = WshShell.Environment("Process")
processorArchitecture = colProcessEnvVars("PROCESSOR_ARCHITECTURE")
if processorArchitecture = "AMD64" then
WshShell.Echo "64-bit"
else
WshShell.Echo "32-bit"
end if

VBScript: Checking to see if a process is currently running

strComputer = "."

Set objWMIService = GetObject("winmgmts:" &_
"{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess In colProcess
if left(objProcess.Name,11) = "Process.exe" then
msgbox "Process is currently running.", 48, "Process is Running"
wscript.quit
end if
Next

Loading up some VBScript for future reference...

My next few posts are just samples of VBScript that I built for work that I want to be able to reference in the future.

As you were.

Tuesday, September 14, 2010