I run DPM for backup and I take full daily backup of protection groups daily. This involves rotating take include previously used one. Each time I insert a new tape, I have to run this command ForceFree-Tape.ps1 -DPMServerName MYDPMSERVER1 -LibraryName "Hewlett Packard LTO Ultrium-3 drive" -TapeLocationList drive-\\.\TapeXXXXXXXX I need a way to automate this and schedule it to runn daily. I have researched this and came up with this solution that involves calling the powershell script from a batch file that is written like this powershell -command "& 'C:\ForceFree-Tape.ps1'" I have schedule this batch file now to run daily at a set time. Testing this fails but running the script directly from DPM Management shell works fine however. I need a way to get this script to running daily at a specific time. I need help and all clues will be appreciated Thanks in Advance
When a process works from the command line, but fails when run as a scheduled task, I usually look for permission issues with the account or accounts that are being used. If you're using a different account for the scheduled process, does it have the same permissions to the objects the script is handling as the one that was used interactively? Does the account that's being used for the scheduled process have "logon as batch" rights on the machine where it is being run?
Another possibility is that your console has a profile that's loading a pssnapin with cmdlets the script uses, but the scheduled task isn't adding that pssnapin.
A further and often overlooked cause for such problems is "casual" programming practices: Instead of fully qualifying all commands and files, people tend to make assumptions that turn out to be invalid. In the current case the OP assumes that the location of powershell.exe is listed in the %path%. Perhaps it isn't. Robust programs would use code like this one: "c:\Program Files\PowerShell\Powershell.exe" -command "& 'C:\ForceFree-Tape.ps1'".
Hi Victor, As well as the suggestions already posted to get you your scheduled task running, you could use Operations Manager to perform this for you if you have it in your environment. I have a post that might be useful to you if this is an option http://www.scdpmonline.org/creating-dpm-powershell-tasks-in-operations-manager.aspx
You need to run: C:\Windows\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft DPM\DPM\bin\dpmshell.psc1" -noexit -command "C:\ForceFree-Tape.ps1"
Thanks Guys, especially to Jonesy. I created a batch file with the command you provided running the batch fle works, so scheduling this to run, I expect complete success, the only little glitch there is that, the command prompt window, does not close at the end of execution. This I attribute to the -noexit parameter, or what do you think?