none
how to write a task to add a regist key to a scom agent machine from a scom server? RRS feed

答案

  • Authoring-->ManagementPackObjects-->Tasks--> New Task-->Agent Tasks-->Commandline, Default MP--> {TaskName}, Task Target: Windows Computer -->PathtoFile:%comspec%, Parameters: "/c reg /add HKLM\Software\"
    Haitao Chen (haidaocht # gmail.com) SCOMMP.Cloudapp.net
    • 已标记为答案 Eronse 2011年8月18日 9:16
    2011年8月18日 7:35
    版主

全部回复

  • Authoring-->ManagementPackObjects-->Tasks--> New Task-->Agent Tasks-->Commandline, Default MP--> {TaskName}, Task Target: Windows Computer -->PathtoFile:%comspec%, Parameters: "/c reg /add HKLM\Software\"
    Haitao Chen (haidaocht # gmail.com) SCOMMP.Cloudapp.net
    • 已标记为答案 Eronse 2011年8月18日 9:16
    2011年8月18日 7:35
    版主
  • Haitao, I need ask further more: this task should contain two conditions: by default, the key's value is a property of a related class, say we already defined it before and we could easy get its property value. and, we should allow customer to input their desired key value manually, how to do that to offer customer a console to input their desired value?
    2011年8月24日 6:29
  • When you submit a task, SCOM support override task parameters, which means you are able to offer customer a console input desired value.

    How ever, the task you create is a Basic Task from SCOM Template, that task doesn't provide any parameter to override, you might need write a custom defined SCOM Module to support that.

    You may also consider SCOM Task Variables, if the desired value could be calculate from given MachineName or some variable SCOM provide, then I suggest you use VBS task.

    If VBS Task with variable still not resolve your issue I can help you implement a SCOM Module.


    Haitao Chen (haidaocht # gmail.com) SCOMMP.Cloudapp.net
    2011年8月25日 2:10
    版主
  • thanks a lot! let me have a try first.
    2011年8月25日 3:08
  • Hi, Haitao, below is what I did today: add a task, and the related writeaction, but it seems that I cannot seal this xml to a MP file, would you please take a look and help me to find out the reason, and if you can tell me how to trace the seal error, I will really appreciate, thanks!

    <Task ID="IBM.WinComputer.AddOverrideableKey" Accessibility="Public" Enabled="true" Target="IBM.WinComputer" Timeout="300" Remotable="true">
            <Category>Custom</Category>
            <WriteAction ID="PO" TypeID="IBM.Windows.AddOverrideableKey">
              <!--<KeyValue>$Target/Property[Type="IBM.SystemX.PowerSupply']/PowerThreshold$</KeyValue>-->
              <KeyValue>500</KeyValue>
            </WriteAction>
          </Task>
        </Tasks>

     

    <WriteActionModuleType ID="IBM.Windows.AddOverrideableKey" Accessibility="Public" Batching="false">
            <Configuration>
              <xsd:element name="KeyValue" type="xsd:int" />
            </Configuration>
            <OverrideableParameters>
              <OverrideableParameter ID="KeyValue" Selector="$Config/KeyValue$" ParameterType="int" />
            </OverrideableParameters>
            <ModuleImplementation>
              <Composite>
                <MemberModules>
                  <WriteAction ID="SWA" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
                    <ScriptName>AddOverrideableKey.vbs</ScriptName>
                    <Arguments>"$Config/KeyValue$"</Arguments>
                    <ScriptBody>
                      <![CDATA[

    SetLocale("en-us")

    ' For debug trace
    Dim oAPI, oReg, RC_Code, progressCode, debug
    Const INFO_LEVEL = 4
    Const HKEY_LOCAL_MACHINE = &H80000002
    Const DEBUG_INFO_KEY = "SOFTWARE\IBM\IBM SCOM MP\Debug"
    Const DEBUG_LEVEL_NAME = "Level"

    Dim PowerCappingValue
    Const IBMHWMP_PowerCapping_KEY = "SOFTWARE\IBM\Systems Management Integrations\PowerCappingValue"
    Const IBMHWMP_PowerCapping_THRESHOLD = "threshold"

    'Setup logging
    debug = -1
    'Set oReg = GetObject("winmgmts://localhost/root/default:StdRegProv")
    set oReg = GetObject( "winmgmts:{impersonationLevel=impersonate}!" & _
                                   "//./root/default:StdRegProv")
    If (not(oReg is nothing)) Then
      RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, DEBUG_INFO_KEY, DEBUG_LEVEL_NAME, debug)
    End If
    Set oAPI = CreateObject("MOM.ScriptAPI")

    If (WScript.Arguments.Count < 1) Then
      Call LogDebugString("Short of arguments count : " & WScript.Arguments.Count, INFO_LEVEL)
      WScript.Quit -1
    End If

    PowerCappingValue = WScript.Arguments.Item(0)

    Call LogDebugString("PowerCappingValue: " + PowerCappingValue, INFO_LEVEL)

    ' Writing powercapping key
    progressCode = ""
    If (not(oReg is nothing)) Then
      RC_Code = -1

      If IsNull(PowerCappingValue) Or IsEmpty(PowerCappingValue) Or PowerCappingValue = "" Then
        'Delete registry value
        RC_Code = oReg.DeleteValue( HKEY_LOCAL_MACHINE, IBMHWMP_PowerCapping_KEY, _
          IBMHWMP_PowerCapping_THRESHOLD )
      Else
        'Create Registry key path
        RC_Code = oReg.CreateKey( HKEY_LOCAL_MACHINE, IBMHWMP_LICENSE_KEY )
        progressCode = "key"
       
        If ( 0 = RC_Code ) Then
          'Create License Feature Level
          RC_Code = oReg.SetStringValue( HKEY_LOCAL_MACHINE, IBMHWMP_PowerCapping_KEY, _
                                         IBMHWMP_PowerCapping_THRESHOLD, PowerCappingValue)
          progressCode = progressCode + ".PowerCappingValue"
        End If
      End If
    End If

    Call LogDebugString("Write : " & progressCode, INFO_LEVEL)

    ' Debug event logging
    Sub LogDebugString(debugString, debugLevel)
      If (Int(debug) >= Int(debugLevel)) Then
        Call oAPI.LogScriptEvent("AddOverrideableKey.vbs", 401, debugLevel, debugString)
      End If
    End Sub
                    ]]>
                    </ScriptBody>
                    <TimeoutSeconds>300</TimeoutSeconds>
                  </WriteAction>
                </MemberModules>
                <Composition>
                  <Node ID="SWA" />
                </Composition>
              </Composite>
            </ModuleImplementation>
            <OutputType>System!System.CommandOutput</OutputType>
            <InputType>System!System.BaseData</InputType>
          </WriteActionModuleType>

    2011年8月25日 7:52
  • First try import your MP to SCOM use MPImport.exe, it will tell you detail error information.

    Then use MPSeal.exe from supporttools under CDImage

    you will need generate a key with SN.exe.

    If you give MPSeal.exe correct arguments, I don't think it will report errors, the key point is fix errors in your MP by import to SCOM.


    Haitao Chen (haidaocht # gmail.com) SCOMMP.Cloudapp.net
    2011年8月26日 3:06
    版主