Create a Deployment Unit With a Limited Booking Window

Modified on Thu, 8 Jun, 2023 at 5:02 PM

Overview

Deployment Units (DUs) are designed to enable the scheduling of users, devices or some other asset type for change or migration. It's common to manage tranches of migrations by location or department. ManagementStudio supports multiple DUs (e.g. one per location/department), but it's also possible to have a single DU for the entire project which can simplify the management of the DUs significantly.


Two of the required settings within a Deployment Unit are the start date and end date. These define when users/devices etc can be scheduled for migration. The deployment team can assign the slots, or users can be sent a self-scheduling links to choose their own slot. 


In the scenario where the single DU approach is chosen to manage the entire project, the DU end date will typically be a long time (a year or more) in the future, because large-scale migrations typically take some time to complete. If self-scheduling links are used users will be offered a migration slot anywhere from now to a year in the future, many will opt for a migration slot in a year's time! How can we avoid this?

A year long DU leaves too much choice!


Implementing a Dynamic DU End Date

By limiting the booking window we ensure migrations are never too far in the future


To ensure that the DU end date is only ever 60 days in the future we can add a four line script to the Deployment Unit. Here's how:

  • If the Deployment Unit doesn't exist, create it and set the Start date to today's date, midnight (00:00)
  • Make a note of the Deployment Unit ID

  • Navigate to Administration -> Deployment Units -> PowerShell Scripts
  • Select the Deployment Units node
  • Click here to add new item

  • Give the script a name such as Set the DU end date
  • Click the Edit button and add the script (see below)
  • Amend the Deployment Unit ID in the script to the one noted earlier
  • Amend the number of days (60) as needed. This is the number of days from today that the DU end date will be set to
  • Click OK
  • Use the column picker button to tick Grant Access 2

  • Set Grant Access 2 to Project Admin
  • Set Schedule 1 to a daily task (the time of day is not critical)
  • Click Save Changes
  • Select the Deployment Units node again
  • Scroll to the right and click Run

  • Once the script has completed open the Deployment Unit and confirm that the end date is set in the future


Summary

This script will run each day so that the Deployment Unit end date is always set 60* days in the future. This ensure that users can only select a migration slot within 60 days from today's date.


* 60 days is the default



Script to add:

# Get the current date, set the time to 23:00
$Today = Get-Date -Hour 23 -Minute 00
 
# Get the DU to be updated
$DU = Get-MSDeploymentUnits -DeployUnitId 1125
 
# Set the end date of the DU variable to 60 days in the future at time 23:00
$DU[0].EndDate = $Today.AddDays(60)
 
# Write this back to the DU
Update-MSDeploymentUnits -Updates $DU[0]