msgbartop
Everybody get your shell on!
msgbarbottom

Running DPM scripts outside of the DPM Management Shell

For the most part, running scripts through the DPM Management Shell works for most people. However, if you have many people that may be using your DPM oriented scripts (any script calling a DPM specific commandlet), it may be less confusing for them to run those through the actual powershell console. Also, this allows you to easily run DPM scripts as a scheduled task as it will invoke the standard powershell console and simply load the needed snapin in your script. Please keep in mind these two things:

  • The DPM CLI MUST be installed on the machine you are running the scripts from. It puts a snapin on the machine that is needed even if running DPM scripts outside of the DPM Management Shell
  • The DPM scripts MUST be run from the same version of the Powershell console as the version of the DPM CLI that is installed(x32 or x64)

Once these pre-requisites have been met, you simply need to put the following in your DPM script (after any input parameters) to run your DPM scripts in the standard powershell console:

1
2
3
4
5
if (!(Get-PSSnapin microsoft.dataprotectionmanager.powershell))
{
write-host "Adding PS Snapin for DPM..." -Fore Green
add-PSSnapin Microsoft.DataProtectionManager.PowerShell
}

This will look on the local machine to see if the DPM snapin is loaded, and if not, load it. You can verify that the snapin has been loaded (or not loaded), by doing the following:

Not loaded:

1
Get-PSSnapin microsoft.dataprotectionmanager.powershell
Get-PSSnapin : No Windows PowerShell snap-in matches criteria microsoft.dataprotectionmanager.powershell.
At line:1 char:13
+ Get-PSSnapin <<<< microsoft.dataprotectionmanager.powershell

Loaded:

1
Get-PSSnapin microsoft.dataprotectionmanager.powershell
Name : Microsoft.DataProtectionManager.PowerShell
PSVersion : 1.0
Description : This is a DPM Powershell snapin.
  • Twitter
  • Facebook
  • LinkedIn
  • Digg
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • Live
  • FriendFeed
  • Ping.fm
  • Print
  • email
  • PDF
  • RSS

Tags: ,

Leave a Comment