none
Please Help with Set-DPMPolicySchedule RRS feed

  • Question

  • Hello Friends,

    I'm trying to modify the synchronization time less than of 15 min, but i get warning message and it do not modify the period.

    PS C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin> $pg = get-protectiongroup -DPMServerName myserver

    PS C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin> Set-DPMPolicySchedule -ProtectionGroup $pg -OffsetInMinutes 10

    WARNING: This is a recurring schedule and will be rounded off to the nearestacceptable value.


    Abdul Razak

    Monday, July 15, 2013 9:37 AM

Answers

  • Sure,

    This should get you started:

    $ProtectionGroupName = "ProtectionGroup"

    $DPMServer = "DPMSERVERHOSTNAME" $PG = Get-ProtectionGroup -DPMServerName $DPMServer | Where-Object {$_.FrindlyName -eq $ProtectionGroupName} $DS = Get-DPMDataSource -ProtectionGroup $PG ForEach ($Source in $DS) { New-DPMRecoveryPoint -Datasource $Source -Disk -DiskRecoveryPointOption withsynchronize }

    Change the $ProtectionGroupName var to the name of your protection group, copy it into notepad and save as a .ps1 file

    Then crack open task scheduler and create a task (launch an application) that runs the script ...the key things you'll need here are:

    Create a New Task (not a basic task)

    On the general tab type a name for the task, select the option to 'Run whether the user is logged on or not' and select the user (service account) that the script will run as.

    On the triggers tab create a new trigger to run every day/weekday etc and to repeat every 10 minutes for a duration of 'indefinately'

    On the actions tab create a new action to 'start a program'

    In the program/script: box type:

    C:\Windows\system32\windowspowershell\v1.0\powershell.exe

    In the Add Arguments (optional:) box type:

    -command ". 'C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\dpmcliinitscript.ps1'; .\<NameOfScript>.ps1

    In the  start in: field type:

    <Drive Letter>:\<Path To Script>\

    Obviously replace <Path To Script> and the other pklaceholders above with the ones on your system

    Click OK twice and type the password of the user

    Test

    • Marked as answer by Abdul-Razak Monday, July 15, 2013 1:52 PM
    Monday, July 15, 2013 12:44 PM
  • The other thing if you cant get it to work is instead of putting the path to the module in your launch cmd line you could just include a line at the beginning of your script:

    Import-Module DataProtectionManager

    That should automatically load the module and allow access to the required cmdlets when the script runs

    Then you could launch your script from the cmd line (elevated) as

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -NoLogo -File "<PATHTOFILE>\<FILENAME>.ps1"

    this shows you a step by step to running PoSH from a scheduled task:

    http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx

    • Marked as answer by Abdul-Razak Thursday, July 18, 2013 4:34 PM
    Thursday, July 18, 2013 12:17 PM

All replies

  • Your actual command would be

    Set-PolicyObjective -ProtectionGroup $PG -SynchronizationFrequencyMinutes 10

    Problem is that this wont work because the minimum synchronisation frequency is 15 minutes.

    You can use options of 15, 30, 45, 60, 120, 240, 360, 720 and 1440 minutes

    Monday, July 15, 2013 10:01 AM
  • I'm trying to achieve less than 15 min of synchronize period. How can that be accomplished ?


    Abdul Razak

    Monday, July 15, 2013 11:11 AM
  • Unfortunately not.

    In my experience though when protecting high change applications I have found that the 15 minute synchronisations overlap (1st one is still in progress by the time the second one is scheduled to kick off) so you often find jobs failing - this issue would only be exaccebated by a 10 minute synchronisation frequency - this may indeed be the reason why it is not there by design.

    Just off the top of my head (and I havent considered the supportability or feasibility of this) you could always script it with Powershell ...you could set your DPM replication schedle to 24 hrs etc and then run a  PoSH script with task scheduler every x minutes that triggers a recovery point on that datasource

    Monday, July 15, 2013 11:39 AM
  • Okay,  can you provide me some sample for how it can setup ?


    Abdul Razak

    Monday, July 15, 2013 12:06 PM
  • Sure,

    This should get you started:

    $ProtectionGroupName = "ProtectionGroup"

    $DPMServer = "DPMSERVERHOSTNAME" $PG = Get-ProtectionGroup -DPMServerName $DPMServer | Where-Object {$_.FrindlyName -eq $ProtectionGroupName} $DS = Get-DPMDataSource -ProtectionGroup $PG ForEach ($Source in $DS) { New-DPMRecoveryPoint -Datasource $Source -Disk -DiskRecoveryPointOption withsynchronize }

    Change the $ProtectionGroupName var to the name of your protection group, copy it into notepad and save as a .ps1 file

    Then crack open task scheduler and create a task (launch an application) that runs the script ...the key things you'll need here are:

    Create a New Task (not a basic task)

    On the general tab type a name for the task, select the option to 'Run whether the user is logged on or not' and select the user (service account) that the script will run as.

    On the triggers tab create a new trigger to run every day/weekday etc and to repeat every 10 minutes for a duration of 'indefinately'

    On the actions tab create a new action to 'start a program'

    In the program/script: box type:

    C:\Windows\system32\windowspowershell\v1.0\powershell.exe

    In the Add Arguments (optional:) box type:

    -command ". 'C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\dpmcliinitscript.ps1'; .\<NameOfScript>.ps1

    In the  start in: field type:

    <Drive Letter>:\<Path To Script>\

    Obviously replace <Path To Script> and the other pklaceholders above with the ones on your system

    Click OK twice and type the password of the user

    Test

    • Marked as answer by Abdul-Razak Monday, July 15, 2013 1:52 PM
    Monday, July 15, 2013 12:44 PM
  • Thanks a lot... :)


    Abdul Razak

    Monday, July 15, 2013 1:52 PM
  • No probs ...just noticed in my initial $PG variable I mis-spelled Friendly Name ...that line should be:

    $PG = Get-ProtectionGroup -DPMServerName $DPMServer | Where-Object {$_.FriendlyName -eq $ProtectionGroupName}

    Cheers
    • Edited by IT Badger Monday, July 15, 2013 2:38 PM spelling!!!!
    Monday, July 15, 2013 2:38 PM
  • Hi,

    When i try to do as your description i'm getting error:

    My script:

    $ProtectionGroupName = SQLBackup
    $DPMServer = fims-mirror
    $PG = Get-ProtectionGroup -DPMServerName $DPMServer | where-Object ($_.FriendlyName -eq $ProtectionGroupName)
    $DS = Get-DPMDataSource -ProtectionGroup $PG
    ForEach ($Source in $DS)
    {
    New-DPMRecoveryPoint -Datasource $Source -Disk -DiskRecoveryPointOption withsynchronize
    }

    error......................

    PS C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin> dpmc1.ps1
    The term 'SQLBackup' is not recognized as the name of a cmdlet, function, scrip
    t file, or operable program. Check the spelling of the name, or if a path was i
    ncluded, verify that the path is correct and try again.
    At C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\DPMC1.ps1:1 char:3
    3
    + $ProtectionGroupName = SQLBackup <<<<
        + CategoryInfo          : ObjectNotFound: (SQLBackup:String) [], CommandNo
       tFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

    The term 'fims-mirror' is not recognized as the name of a cmdlet, function, scr
    ipt file, or operable program. Check the spelling of the name, or if a path was
     included, verify that the path is correct and try again.
    At C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\DPMC1.ps1:2 char:2
    5
    + $DPMServer = fims-mirror <<<<
        + CategoryInfo          : ObjectNotFound: (fims-mirror:String) [], Command
       NotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

    Get-DPMProtectionGroup : Cannot validate argument on parameter 'DPMServerName'.
     The argument is null or empty. Supply an argument that is not null or empty an
    d then try the command again.
    At C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\DPMC1.ps1:3 char:4
    1
    + $PG = Get-ProtectionGroup -DPMServerName <<<<  $DPMServer | where-Object ($_.
    FriendlyName -eq $ProtectionGroupName)
        + CategoryInfo          : InvalidData: (:) [Get-DPMProtectionGroup], Param
       eterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Inter
       nal.EnterpriseStorage.Dls.UI.Cmdlet.ProtectionCmdLets.GetProtectionGroup


    JobCategory         Status              ProtectionGroupName DataSources
    -----------         ------              ------------------- -----------
    ShadowCopy          InProgress          SQLBackup           FIMS\FIMSCOT
    ShadowCopy          InProgress          SQLBackup           FIMS\FIMSONE_P2


    PS C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin>

    and also in task scheduler it is showing error as invalid directory. Below is the path: which i have given

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    -command"."C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\DpmCliInitScript.ps1";.\dpmc1.ps1
    "C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\DPMC1.ps1"


    Abdul Razak

    Monday, July 15, 2013 6:17 PM
  • Hey,

    Did you wrap the String Variables in Double Quotes as in:

    $ProtectionGroupName = "SQLBackup"
    $DPMServer = "fims-mirror"

    If you leave them the way that they are in your reply above the script will fail ...that's what the first 2 error messages indicate.

    Cheers.

    Tuesday, July 16, 2013 7:24 AM
  • No, i haven't tried that. let me check and shall update.

    how about error in task scheduler ?  'invalid directory....'


    Abdul Razak

    Tuesday, July 16, 2013 1:42 PM
  • C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    -command"."C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\DpmCliInitScript.ps1";.\dpmc1.ps1

    "C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\DPMC1.ps1"

    ^^the above line ("C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\DPMC1.ps1") are you using this in the 'start in field'?

    If so then you only want to use the below:

    C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\

    The start in field tells Powershell the folder that your script is located in and thus the folder from which to run it from ..sorry my explanation wasnt clear earlier - this should be the folder path to your script and shouldnt actually include the name of the script

    Also to confirm you are running this from the DPM server arent you ...you dont have to but you do need to make sure that if you're not then you do have the DPM remote administration tools (console and shell) installed on the PC it is to be run from.

    Cheers

    Tuesday, July 16, 2013 1:52 PM
  • okay,

    Yes I'm running this on DPM server. 

    Let me give a try by tomorrow.


    Abdul Razak

    Tuesday, July 16, 2013 4:01 PM
  • okay, now my script is working but my task scheduler is giving error.

    when i try to execute the powershell -command"'C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\DpmCliInitScript.ps1';.\dpmc1.ps1"

    I get error as ./dpmc1.ps1 is not recognized  as the name of cmdlet.


    Abdul Razak

    Wednesday, July 17, 2013 7:57 AM
  • Ok first lets confirm that you've got the command right.

    In the program or script box you have:

    C:\Windows\system32\windowspowershell\v1.0\powershell.exe

    In the add arguments box you have:

    -command ". 'C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\dpmcliinitscript.ps1'; .\<NameOfScript>.ps1

    That error is usually flagged when the script doesnt exist ...are you sure it is called 'DPMC1.ps1' - when you saved it in notepad you didnt leave it as a text file did you - It isnt called DPMC1.ps1.txt is it?

    Once you've confimred that the 'DPMC1.ps1' script exists in your C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin directory and the syntax above is correct test again

    Cheers

    Wednesday, July 17, 2013 10:34 AM
  • Hi

    I tried running this on powershell directly as below:

    powershell -command ". 'C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\dpmcliinitscript.ps1'; .\dpmc1.ps1

    but it returns in >>> on cli



    Abdul Razak

    Wednesday, July 17, 2013 12:46 PM
  • Best way to test this is from the cmd prompt as this is exactly what the scheduled task will do

    If you cd to the directory of the script (C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin)

    then run (all 1 line):

    C:\Windows\system32\windowspowershell\v1.0\powershell.exe -command ". 'C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\dpmcliinitscript.ps1'; .\dpmc1.ps1

    see what errors are returned

    Also while you are in the C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin directory run dir and see if a file exists 'dpmc1.ps1' - if not the that's your problem

    Cheers

    Wednesday, July 17, 2013 2:47 PM
  • check these screen shots....


    Abdul Razak

    Wednesday, July 17, 2013 6:09 PM
  • With regards to the above screenshot run the command from a cmd.exe prompt (elevated) not from powershell/the dpm shell like I mentioned to test the syntax.

    The command will call powershell, then import the dpm module, then launch the script

    C:\Windows\system32\windowspowershell\v1.0\powershell.exe -command ". 'C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\dpmcliinitscript.ps1'; .\DPMC1.ps1


    Make sure you have changed the cmd.exe directory to the directory in which your script is located. If this works then....

    save this as an xml file and in task scheduler select the option to import a task, then browse to this xml file.

    This works for me

    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
      <RegistrationInfo>
        <Date>2013-07-18T08:49:15.1699265</Date>
        <Author>DOMAIN\service.account</Author>
      </RegistrationInfo>
      <Triggers>
        <TimeTrigger>
          <Repetition>
            <Interval>PT10M</Interval>
            <StopAtDurationEnd>false</StopAtDurationEnd>
          </Repetition>
          <StartBoundary>2013-07-18T20:30:00</StartBoundary>
          <Enabled>true</Enabled>
        </TimeTrigger>
      </Triggers>
      <Principals>
        <Principal id="Author">
          <UserId>DOMAIN\service.account</UserId>
          <LogonType>Password</LogonType>
          <RunLevel>HighestAvailable</RunLevel>
        </Principal>
      </Principals>
      <Settings>
        <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
        <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
        <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
        <AllowHardTerminate>true</AllowHardTerminate>
        <StartWhenAvailable>false</StartWhenAvailable>
        <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
        <IdleSettings>
          <StopOnIdleEnd>true</StopOnIdleEnd>
          <RestartOnIdle>false</RestartOnIdle>
        </IdleSettings>
        <AllowStartOnDemand>true</AllowStartOnDemand>
        <Enabled>true</Enabled>
        <Hidden>false</Hidden>
        <RunOnlyIfIdle>false</RunOnlyIfIdle>
        <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
        <UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>
        <WakeToRun>false</WakeToRun>
        <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
        <Priority>7</Priority>
      </Settings>
      <Actions Context="Author">
        <Exec>
          <Command>C:\Windows\system32\windowspowershell\v1.0\powershell.exe</Command>
          <Arguments>-command ". 'C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin
    \dpmcliinitscript.ps1'; .\DPMC1.ps1</Arguments>
          <WorkingDirectory>C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\</WorkingDirectory>
        </Exec>
      </Actions>
    </Task>

    EDIT: Also you havent got a space between the -command" - it should be -command "

    Copy and paste the command ...it's easier that way ;)


    • Edited by IT Badger Thursday, July 18, 2013 12:09 PM edit
    Thursday, July 18, 2013 11:55 AM
  • The other thing if you cant get it to work is instead of putting the path to the module in your launch cmd line you could just include a line at the beginning of your script:

    Import-Module DataProtectionManager

    That should automatically load the module and allow access to the required cmdlets when the script runs

    Then you could launch your script from the cmd line (elevated) as

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -NoLogo -File "<PATHTOFILE>\<FILENAME>.ps1"

    this shows you a step by step to running PoSH from a scheduled task:

    http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx

    • Marked as answer by Abdul-Razak Thursday, July 18, 2013 4:34 PM
    Thursday, July 18, 2013 12:17 PM
  • Thanks dear,

    U rock.... the last trick import-module within  the script worked for me.


    Abdul Razak

    Thursday, July 18, 2013 4:28 PM
  • Glad you finally got it working! :)
    • Edited by IT Badger Thursday, July 18, 2013 4:40 PM edit
    Thursday, July 18, 2013 4:40 PM