Creating DPM PowerShell Tasks in Operations Manager

Performing general administrative DPM tasks can be quite time consuming so why not get Operations Manager to do them for you.  As with most new products coming out of Microsoft, any administrative task (and generally a lot more) can be scripted in PowerShell which can allow for tasks to be easily actioned remotely and much more efficiently.  Taking this one step futher though, you can create tasks and rules in Operations Manager that use these scripts to give you one central point of administration.

As an example I will use the PowerShell script written by Kapil Malhotra which automatically grows your replica and shadow copy volume sizes (http://blogs.technet.com/dpm/archive/2007/07/10/cli-grow-your-replica-and-shadow-copy-volume-sizes-automatically.aspx).  Basically this script will grow the replica volume by 5GB if it has breached a threshold of 500MB and grow the shadow copy volume by 5GB if it has breached a threshold of 1GB.  Now, you can simply run this script on your DPM server to prevent the risk of not protecting your data but this still can be quite an administrative overhead to manage.  This is particularly true if you have multiple DPM servers, the number of DPM servers in your environment is likely to grow and if you want to make a change to the script that applies to all the servers.  This is where Operations Manager comes in.

With Operations Manager up and running with agents deployed to all DPM servers and with the latest Data Protection Manager management pack installed, all your DPM servers should be discovered.  And, all the discovered DPM servers will be objects in the DPM Server class which can be used to target rules and tasks at.  With that in mind, I'll finally get to how to create a DPM task in Operations Manager.

Operations Manager Console

First of all, this is all based on Operations Manager 2007 R2.  With some changes you can make this work on Operations Manager SP1 but that is not covered here. 

1.  Build the PowerShell script to perform the DPM task you require.  In this case, as stated above, I am using a pre-written PS script from the MS Ctrl-P blog which you can download here.

2.  Add these two lines to the top of the script.  The first line enables Operations Manager to pass the DPM server name to the script and the second line loads the DPM PowerShell snapin.

DPM Script

3.  Remove the line $dpmservername = &"hostname"Click here for the download of the ammended script.

4.  Open the Operations Manager 2007 R2 Authoring Console.  Click File, New..., select Empty Management Pack and enter a Management Pack Identity (I have used DPMTask).  Click Next.

New MP

5.  Enter a Management Pack display name and optional description, then click Create.

6.  Once the MP has been created, click File, Management Pack Properties.  In the Properties window that opens, select the References tab, the click Add Reference....  Navigate to and select the DPM management pack file (Microsoft.Windows.SystemCenterDPM).  Click OK when the reference has been successfully added as the image below.

MP References

7.  Select the Health Model pane, expand Tasks in the Health Model tree and select Agent Tasks.

8.  Right click in the Agent Tasks pane on the right and select New, Custom Task....  Enter a unique identifier for the new task and click OK (I have used DPMTask.AutoGrow). 

9.  When the task window opens, enter a display name and select the target Microsoft.Windows.SystemCenterDPM.DPMServer.

DPM Task - GeneralS

10.  Click on the Configuration tab and click the link, Browse for a type....  Select the Microsoft.Windows.PowerShellWriteAction and enter a module ID.  Click OK.

DPM Task - Module Type

11.  Now back on the Configuration tab, click Edit....

  • Between the ScriptName tags, enter a name for the script (autogrow.ps1).
    • <ScriptName>autogrow.ps1</ScriptName>
  • Between the ScriptBody tags, paste in the PowerShell script.
    • <ScriptBody>powershell script</ScriptBody>
  • After the </ScriptBody> task, enter the following:
    • <Parameters>
    •   <Parameter>
    •     <Name>DPMServer</Name>
    •     <Value></Value>
    •   </Parameter>
    • </Parameters>
  • Between the TimeoutSeconds tags, enter a larger value like 6000.
    • <TimeoutSeconds>6000</TimeoutSeconds>

Save the file and close.

DPM Task - Script Details

12.  Click the Value field next the >>Value parameter and select (Host=WindowsServer), Principal Name (Windows Computer)

>>Value

This is done to make sure the correct DPM server name is passed so the script runs on the selected server.

13.  Click OK.

That's it done, the DPM task has been created.  Now you can either save the new management pack and import it into Operations Manager or you can select Tools, Export MP to Management Group... from within the Authoring Console.

Once imported, select the Monitoring pane and expand Data Protection Manager 2007.  Click the DPM Server State view and select one of the DPM servers and in the Actions pane you will see your new Auto Grow task.

DPM Task in Operations Manager

Click Auto Grow and run task.  Once the task has completed it will output the results.

Completed DPM Task

How awesome is that ?!?!

I know this migh look a bit long winded but when you do it once, you will will see that it is actually quite simple. 

Enjoy.



David  ...
Click here to play