I have attached a mp that shows the basic idea. I havn't testet it, so could be needing som debugging.
Regards Henrik Fra: [email protected] [mailto:[email protected]] På vegne af Henrik Andersen Sendt: 3. maj 2017 00:09 Til: [email protected] Emne: [msmom] SV: SCOM 2016 Agent tasks - Powershell support Hi! Oh you can do tasks with powershell. You just have get your hands on the xml:) Fra: [email protected]<mailto:[email protected]> [mailto:[email protected]] På vegne af Sylvain Hamel Sendt: 2. maj 2017 23:01 Til: [email protected]<mailto:[email protected]> Emne: [msmom] SCOM 2016 Agent tasks - Poweugged.rshell support Hi Guys, Does anyone know if SCOM 2016 supports Powershell scripts as tasks ? Currently with SCOM 2012, you can only do .js or .vbs. You can call Powershell.exe with a one-liner but that's not optimal. Sylvain Hamel IT Technical Leader, Core Infrastructure Applications McGill University - Network and Communication Services
<?xml version="1.0" encoding="utf-8"?> <ManagementPack SchemaVersion="2.0" ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Manifest> <Identity> <ID>HKA00.SCOM.PS.Script</ID> <Version>1.0.0.50</Version> </Identity> <Name>HKA00.SCOM.PS.Script</Name> <References> <Reference Alias="SC"> <ID>Microsoft.SystemCenter.Library</ID> <Version>7.0.8433.0</Version> <PublicKeyToken>31bf3856ad364e35</PublicKeyToken> </Reference> <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> <TypeDefinitions> <ModuleTypes> <ProbeActionModuleType ID="HKA00.SCOM.PS.Script.Server.Action" Accessibility="Public" Batching="false" PassThrough="false"> <Configuration> <xsd:element minOccurs="1" name="Server" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> <xsd:element minOccurs="1" name="Debug" type="xsd:boolean" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> </Configuration> <OverrideableParameters> <OverrideableParameter ID="Server" Selector="$Config/Server$" ParameterType="string" /> <OverrideableParameter ID="Debug" Selector="$Config/Debug$" ParameterType="bool" /> </OverrideableParameters> <ModuleImplementation Isolation="Any"> <Composite> <MemberModules> <ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.PowerShellProbe"> <ScriptName>PSScript.ps1</ScriptName> <ScriptBody> # Parameters param([string]$Server,[string]$debug) </ScriptBody> <Parameters> <Parameter> <Name>Server</Name> <Value>$Config/Server$</Value> </Parameter> <Parameter> <Name>debug</Name> <Value>$Config/Debug$</Value> </Parameter> </Parameters> <TimeoutSeconds>300</TimeoutSeconds> </ProbeAction> </MemberModules> <Composition> <Node ID="Script" /> </Composition> </Composite> </ModuleImplementation> <OutputType>Windows!Microsoft.Windows.SerializedObjectData</OutputType> <InputType>System!System.BaseData</InputType> </ProbeActionModuleType> <ProbeActionModuleType ID="HKA00.SCOM.PS.Script.Server.Probe" Accessibility="Public" Batching="false" PassThrough="false"> <Configuration> <xsd:element minOccurs="1" name="Server" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> <xsd:element minOccurs="1" name="Debug" type="xsd:boolean" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> </Configuration> <OverrideableParameters> <OverrideableParameter ID="Server" Selector="$Config/Server$" ParameterType="string" /> <OverrideableParameter ID="Debug" Selector="$Config/Debug$" ParameterType="bool" /> </OverrideableParameters> <ModuleImplementation Isolation="Any"> <Composite> <MemberModules> <ProbeAction ID="Probe" TypeID="HKA00.SCOM.PS.Script.Server.Action"> <Server>$Config/Server$</Server> <Debug>$Config/Debug$</Debug> </ProbeAction> </MemberModules> <Composition> <Node ID="Probe" /> </Composition> </Composite> </ModuleImplementation> <OutputType>Windows!Microsoft.Windows.SerializedObjectData</OutputType> <InputType>System!System.BaseData</InputType> </ProbeActionModuleType> </ModuleTypes> </TypeDefinitions> <Monitoring> <Tasks> <Task ID="HKA00.SCOM.PS.Script.Server.Task" Accessibility="Internal" Target="SC!Microsoft.SystemCenter.HealthService" Enabled="true" Timeout="300" Remotable="true"> <Category>Maintenance</Category> <ProbeAction ID="PA" TypeID="HKA00.SCOM.PS.Script.Server.Probe"> <Server>fqdn of server</Server> <Debug>false</Debug> </ProbeAction> </Task> </Tasks> </Monitoring> <LanguagePacks> <LanguagePack ID="ENU" IsDefault="true"> <DisplayStrings> <DisplayString ElementID="HKA00.SCOM.PS.Script.Server.Task"> <Name>PS Script Server Task</Name> <Description>PS Script Server Task</Description> </DisplayString> </DisplayStrings> <KnowledgeArticles></KnowledgeArticles> </LanguagePack> </LanguagePacks> /ManagementPack>
