Skip to content

Instantly share code, notes, and snippets.

@shadeon
Created November 22, 2016 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadeon/4b40e198ee86719ffed6f4483e5a5f83 to your computer and use it in GitHub Desktop.
Save shadeon/4b40e198ee86719ffed6f4483e5a5f83 to your computer and use it in GitHub Desktop.
Sample SCOM management pack that launches the Squared Up from the SCOM console
<?xml version="1.0" encoding="utf-8"?>
<ManagementPack SchemaVersion="2.0" ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Manifest>
<Identity>
<ID>LaunchSquaredUp</ID>
<Version>1.0.0.0</Version>
</Identity>
<Name>LaunchSquaredUp</Name>
<References>
<Reference Alias="Windows">
<ID>Microsoft.Windows.Library</ID>
<Version>7.5.8501.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="System">
<ID>System.Library</ID>
<Version>7.5.8501.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
</References>
</Manifest>
<Categories>
<Category ID="LaunchSquaredUp.ConsoleTask.LaunchFromAlert.Category" Target="LaunchSquaredUp.ConsoleTask.LaunchFromAlert" Value="System!System.Internal.ManagementPack.ConsoleTasks.Alert" />
<Category ID="LaunchSquaredUp.ConsoleTask.LaunchFromAlertObject.Category" Target="LaunchSquaredUp.ConsoleTask.LaunchFromAlertObject" Value="System!System.Internal.ManagementPack.ConsoleTasks.Alert" />
<Category ID="LaunchSquaredUp.ConsoleTask.LaunchFromComputer.Category" Target="LaunchSquaredUp.ConsoleTask.LaunchFromComputer" Value="System!System.Internal.ManagementPack.ConsoleTasks.MonitoringObject" />
</Categories>
<Presentation>
<ConsoleTasks>
<ConsoleTask ID="LaunchSquaredUp.ConsoleTask.LaunchFromAlert" Accessibility="Public" Enabled="true" Target="System!System.Entity" RequireOutput="false">
<Assembly>Res.LaunchSquaredUp.ConsoleTask.LaunchFromAlert</Assembly>
<Handler>ShellHandler</Handler>
<Parameters>
<Argument Name="WorkingDirectory" />
<Argument Name="Application">cmd</Argument>
<Argument>/C "start http://squpnightly/SquaredUpv3/drilldown/scomalert?id=$Id$"</Argument>
</Parameters>
</ConsoleTask>
<ConsoleTask ID="LaunchSquaredUp.ConsoleTask.LaunchFromAlertObject" Accessibility="Public" Enabled="true" Target="System!System.Entity" RequireOutput="false">
<Assembly>Res.LaunchSquaredUp.ConsoleTask.LaunchFromAlertObject</Assembly>
<Handler>ShellHandler</Handler>
<Parameters>
<Argument Name="WorkingDirectory" />
<Argument Name="Application">cmd</Argument>
<Argument>/C "start http://squpnightly/SquaredUpv3/drilldown/scomobject?id=$MonitoringObjectId$"</Argument>
</Parameters>
</ConsoleTask>
<ConsoleTask ID="LaunchSquaredUp.ConsoleTask.LaunchFromComputer" Accessibility="Public" Enabled="true" Target="Windows!Microsoft.Windows.Computer" RequireOutput="false">
<Assembly>Res.Microsoft.Windows.Server.Computer.OpenPowerShell</Assembly>
<Handler>ShellHandler</Handler>
<Parameters>
<Argument Name="WorkingDirectory" />
<Argument Name="Application">powershell.exe </Argument>
<Argument>-noprofile -Command "&amp; { <![CDATA[Param([String]$computerFQDN)
$mgArgs = @{}
$sdkService = Get-Service -Name omsdk -ErrorAction SilentlyContinue
if ( $sdkService -eq $null -or $sdkService.Status -eq [System.ServiceProcess.ServiceControllerStatus]::Running)
{
$key = 'HKCU:Software\Microsoft\Microsoft Operations Manager\3.0\User Settings'
$mgArgs['ComputerName'] = (Get-ItemProperty -Path $key -Name SDKServiceMachine).SdkServiceMachine
$credsRequired = (Get-ItemProperty -Path $key -Name SDKServiceMachineRequiresCredentials -ErrorAction SilentlyContinue).SDKServiceMachineRequiresCredentials
if ($credsRequired -ne $null -and $credsRequired -eq 'True')
{
$mgArgs['Credential'] = Get-Credential -Message 'Please provide credentials to connect to SCOM.'
}
}
Import-Module OperationsManager
New-SCOMManagementGroupConnection @mgArgs
## Get Windows Computer class
$computerClass = Get-SCOMClass -Name 'Microsoft.Windows.Computer'
## Get SCOM object
$scomObject = (Get-SCOMClass -Name Microsoft.Windows.Computer| Get-SCOMClassInstance | where {$_.FullName -eq ('Microsoft.Windows.Computer:' + $computerFQDN)})
if ($scomObject -ne $null)
{
Start-Process -FilePath ('http://squpnightly/SquaredUpv3/drilldown/scomobject?id=' + $scomObject.Id)
}
]]> }"</Argument>
<Argument>"$Target/Property[Type='Windows!Microsoft.Windows.Computer']/PrincipalName$"</Argument>
</Parameters>
</ConsoleTask>
</ConsoleTasks>
</Presentation>
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="true">
<DisplayStrings>
<DisplayString ElementID="LaunchSquaredUp">
<Name>Launch Squared Up Console Tasks</Name>
<Description>Adds console tasks that let you open Squared Up from the SCOM console.</Description>
</DisplayString>
<DisplayString ElementID="LaunchSquaredUp.ConsoleTask.LaunchFromAlert">
<Name>View alert in Squared Up</Name>
<Description>Opens the alert in Squared Up using your default browser.</Description>
</DisplayString>
<DisplayString ElementID="LaunchSquaredUp.ConsoleTask.LaunchFromAlertObject">
<Name>View Object in Squared Up</Name>
<Description>Opens the object in Squared Up using your default browser.</Description>
</DisplayString>
<DisplayString ElementID="LaunchSquaredUp.ConsoleTask.LaunchFromComputer">
<Name>View computer in Squared Up</Name>
<Description>Opens the computer in Squared Up using your default browser.</Description>
</DisplayString>
</DisplayStrings>
<KnowledgeArticles></KnowledgeArticles>
</LanguagePack>
</LanguagePacks>
<Resources>
<Assembly ID="Res.LaunchSquaredUp.ConsoleTask.LaunchFromAlert" Accessibility="Public" FileName="LaunchSquaredUp.ConsoleTask.LaunchFromAlert" HasNullStream="true" QualifiedName="LaunchSquaredUp.ConsoleTask.LaunchFromAlert" />
<Assembly ID="Res.LaunchSquaredUp.ConsoleTask.LaunchFromAlertObject" Accessibility="Public" FileName="LaunchSquaredUp.ConsoleTask.LaunchFromAlertObject" HasNullStream="true" QualifiedName="LaunchSquaredUp.ConsoleTask.LaunchFromAlertObject" />
<Assembly ID="Res.Microsoft.Windows.Server.Computer.OpenPowerShell" Accessibility="Public" FileName="Microsoft.Windows.Server.Computer.OpenPowerShell" HasNullStream="true" QualifiedName="Microsoft.Windows.Server.Computer.OpenPowerShell" />
</Resources>
</ManagementPack>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment