Modify the deadline time of an ADR Deployment with PowerShell

Using an Automatic Deployment Rule in ConfigMgr 2012 helps automating your Software Update deployments a lot. In the case where you configure the ADR to run at a specific time after Patch Tuesday, lets say on Wednesday evening at 23.00 PM, and you’d want the deployment deadline time to be 3 days ahead on Saturday at 02.00 AM, you’ll see that it’s not possible within the ConfigMgr console. I’ve at least not found an easy way to do so. Let’s try to illustrate it a bit more in detail.
In this case I have an ADR for my lab environment clients that is set to be run at 12/1/2013 11:10 AM.
On the Deployment Schedule tab, I’ve configured the Installation Deadline to be 7 days ahead. The effective installation deadline time for this deployment would be on the 12/8/2013 3:10 PM. I’ve not yet found out why ConfigMgr is adding a few extra hours to the installation deadline time, but I’m assuming that it’s for allowing distribution to happen across all Distribution Points.
How can we change this installation deadline time then to be set to a time and date we’d like? It’s actually not that hard. We’d have to write a few lines of either PowerShell or another scripting language to get the desired results. Let’s take a look at how we can accomplish this with PowerShell.
The script that we’ll use is the following:











[ValidateScript({$_.Length -eq 4})] $DeadlineHours ) $CurrentDate = (Get-Date).AddDays(-$CreationTimeDays).ToShortDateString() $Deadline = ([System.Management.ManagementDateTimeConverter]::ToDmtfDateTime((Get-Date).AddDays($DeadlineDays))).Split(“.”).SubString(0,8)[0] $Time = “$($DeadlineHours)00” $ADRClientDeployment = Get-WmiObject -Namespace “root\sms\site_$($SiteCode)” -Class SMS_UpdateGroupAssignment -ComputerName $SiteServer foreach ($Deployment in $ADRClientDeployment) { $CreationDate = $Deployment.ConvertToDateTime($Deployment.CreationTime).ToShortDateString() $DeploymentName = $Deployment.AssignmentName if ($CreationDate -gt $CurrentDate) { Write-Output “Deployment to be modified: `n$($DeploymentName)” try { $Deployment.EnforcementDeadline = “$($Deadline)$($Time).000000+***” $Deployment.Put() | Out-Null if ($?) { Write-Output “`nSuccessfully modified deployment`n” } } catch { Write-Output “`nERROR: $($_.Exception.Message)” } } }

Save this script as e.g. Set-ADRDeploymentTime.ps1. The script itself accepts a few parameters. Here’s a description of each of them:

  • SiteServer
    Should be a NetBIOS or FQDN of your site server
  • SiteCode
    Enter the site code of the specified site server
  • CreationTimeDays
    The number specified here will determine what deployments will be modified depending on the creation time of each deployment
  • DeadlineDays
    Specify a number of days ahead you would want the new installation deadline time to be
  • DeadlineHours
    Specified in 4 digits, e.g. “1400” is equal to 02:00 PM. It’s important that you specify value for this parameter within quotations

Let’s say that we’d want to change the installation deadline time to 7 days ahead, at 02:00 AM and only on the deployments created yesterday. Execute the script by running the following command line elevated and as a ConfigMgr Full Administrator:

.\Set-ADRDeploymentTime.ps1 -SiteServer -SiteCode CAS -CreationTimeDays 1 -DeadlineDays 7 -DeadlineHours "0200"

NOTE! It’s important that you remember the quotation marks around the DeadlineHours, or the script will fail.
If we now take a look at the properties of the deployment, we can see that installation deadline has changed to what we set it to:
Why should you change this? Well it’s all about control. If you’re familiar with how maintenance windows work you’ll probably think to yourself, why don’t I just schedule the ADR to be evaluated at a certain time instead so the installation deadline time is set within the maintenance window. Well, you can of course do so, but if that time period happens to be when you’re server load is at it’s peak you can use this method instead. And in order to automate this process, create a scheduled task that is configured to run at a certain amount of time after the ADR evaluation schedule.


Nickolaj Andersen

Chief Technical Architect and Enterprise Mobility MVP since 2016. Nickolaj has been in the IT industry for the past 10 years specializing in Enterprise Mobility and Security, Windows devices and deployments including automation. Awarded as PowerShell Hero in 2015 by the community for his script and tools contributions. Creator of ConfigMgr Prerequisites Tool, ConfigMgr OSD FrontEnd, ConfigMgr WebService to name a few. Frequent speaker at conferences such as Microsoft Ignite, NIC Conference and IT/Dev Connections including nordic user groups.


  • Hello Nickolaj,
    Do you have and suggestions for targeting one ADR, versus all ADR’s in the site?

    • Hi Mark,
      Not sure why you’d want to do that (do you want to set the same time or different times for them?), but extending the script to retrieve all instances of ADR’s shouldn’t be that hard. When you’ve retrieved all instances, simply just loop through them one at a time and make the changes.
      How many ADR’s do you have that needs to be changed?

      • We have several ADR’s for different patching groups, including different dev and production environments. I find the current deadline determination a bit clunky and unreliable. I’m looking for a powershell script that lets me target one ADR deployment at a time. I’m trying to make this easier on other team members who may need to step in.

    • Hi Greg,
      I believe that you’ve confused me with Henk, my name is Nickolaj and this is my blog 🙂
      I’d be glad if you’d update your post with my name instead. Really cool script you put together though, I bet that others will find it very useful.



Do you want to be notified of new posts on our site?

Please enter your email address below:

Categories use cookies to ensure that we give you the best experience on our website.