I need to Automate ForceFree-Tape cmdlet

Discussion in 'Scripting' started by Victor Asuquo, Jul 18, 2009.

  1. 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

    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
    Victor Asuquo, Jul 18, 2009
    1. Advertisements

  2. Victor Asuquo

    Rob Campbell Guest

    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?
    Rob Campbell, Jul 18, 2009
    1. Advertisements

  3. Victor Asuquo

    Rob Campbell Guest

    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.
    Rob Campbell, Jul 18, 2009
  4. 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 "&
    Pegasus [MVP], Jul 18, 2009
  5. Victor Asuquo

    David Allen Guest

    David Allen, Jul 21, 2009
  6. Victor Asuquo

    Jonesy Guest

    You need to run:

    C:\Windows\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile
    "C:\Program Files\Microsoft DPM\DPM\bin\dpmshell.psc1" -noexit -command
    Jonesy, Jul 21, 2009
  7. Victor Asuquo

    VascoSputs Guest

    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?
    VascoSputs, Jul 23, 2009
  8. Victor Asuquo

    Jonesy Guest

    Not a problem. Removing noexit should do the trick.
    Jonesy, Jul 24, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.