Citrix Virtual Apps and Desktops SDK

Set-ProvVMUpdateTimeWindow

Introduced in: Citrix Virtual Apps and Desktop 7 2305

Sets a time window on provisioned virtual machines during which they will undergo a property update on boot.

Syntax

Set-ProvVMUpdateTimeWindow
   [-StartTimeInUTC <String>]
   [-StartsNow]
   [-DurationInMinutes <Int32>]
   -ProvisioningSchemeName <String>
   [-LoggingId <Guid>]
   [<CitrixCommonParameters>]
   [<CommonParameters>]
<!--NeedCopy-->
Set-ProvVMUpdateTimeWindow
   [-StartTimeInUTC <String>]
   [-StartsNow]
   [-DurationInMinutes <Int32>]
   -ProvisioningSchemeName <String>
   -VMName <String[]>
   [-LoggingId <Guid>]
   [<CitrixCommonParameters>]
   [<CommonParameters>]
<!--NeedCopy-->
Set-ProvVMUpdateTimeWindow
   [-StartTimeInUTC <String>]
   [-StartsNow]
   [-DurationInMinutes <Int32>]
   -ProvisioningSchemeUid <Guid>
   [-LoggingId <Guid>]
   [<CitrixCommonParameters>]
   [<CommonParameters>]
<!--NeedCopy-->
Set-ProvVMUpdateTimeWindow
   [-StartTimeInUTC <String>]
   [-StartsNow]
   [-DurationInMinutes <Int32>]
   -ProvisioningSchemeUid <Guid>
   -VMName <String[]>
   [-LoggingId <Guid>]
   [<CitrixCommonParameters>]
   [<CommonParameters>]
<!--NeedCopy-->

Description

Provides the ability to synchronize the properties of existing virtual machines with any changes occurred on the provisioning scheme with Set-ProvScheme and any configuration applied with Set-ProvVM.

This cmdlet defines a time window where a property update will take place against either specific machines in a catalog or an entire catalog. The update will take place when the machine is next booted within the time window. Note that running this command does not make the machine automatically reboot or turn on sometime within the time window to apply the update. The power action to initiate the update must either be performed as a part of an autoscale schedule or manually through Studio or the New-BrokerHostingPowerAction cmdlet within the time window. If the time window passes before the machine is booted successfully, the update will not apply and will have to be set again with this cmdlet.

On each VM an update window is set, ProvisioningSchemeUpdateRequested defines the start of the time window and ProvisioningSchemeUpdateUntil defines the end of the time window.

After the update, ProvisioningSchemeVersion on the VM will be updated to match the current version of the ProvScheme, and the ProvVMConfigurationVersion will match the latest configuration on the VM.

Examples

EXAMPLE 1

Change the MachineProfile for the azure-catalog provisioning scheme with Set-ProvScheme, this increments the provisioning scheme version to 2. Set all 4 VMs in azure-catalog to have a property update in the time window starting 3/12/2022 at 3am UTC and lasting for 60 minutes. Times for ProvisioningSchemeUpdateRequested and ProvisioningSchemeUpdateUntil are displayed in local time (EST in this case). If a catalog machine is booted in that time window, it will update to the latest provisioning scheme settings. The first restart of machine azu01 in this example performs no action since it’s before the time window starts, while the second restart is within the window, so the machine is updated and the time window is cleared.

Set-ProvScheme -ProvisioningSchemeName azure-catalog -MachineProfile "XDHyp:\HostingUnits\azure-unit\machineprofile.folder\new-template.vm"

Get-ProvScheme | select ProvisioningSchemeName, ProvisioningSchemeVersion
ProvisioningSchemeName   ProvisioningSchemeVersion
-----------------------  --------------------------
azure-catalog                                     2

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil
------       -------------------------  ---------------------------------  -----------------------------
azu01                              1    
azu02                              1   
azu03                              1   
azu04                              1  

Set-ProvVMUpdateTimeWindow -ProvisioningSchemeName azure-catalog -StartTimeInUTC "3/12/2022 3am" -DurationInMinutes 60

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil
------       -------------------------  ---------------------------------  -----------------------------
azu01                              1               3/11/2022  11:00:00 PM         3/12/2022  12:00:00 AM
azu02                              1               3/11/2022  11:00:00 PM         3/12/2022  12:00:00 AM
azu03                              1               3/11/2022  11:00:00 PM         3/12/2022  12:00:00 AM
azu04                              1               3/11/2022  11:00:00 PM         3/12/2022  12:00:00 AM

Get-Date

Thursday, March 10, 2022 1:53:41 PM

New-BrokerHostingPowerAction -Action "Restart" -MachineName azu01

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil
------       -------------------------  ---------------------------------  -----------------------------
azu01                              1               3/11/2022  11:00:00 PM         3/12/2022  12:00:00 AM
azu02                              1               3/11/2022  11:00:00 PM         3/12/2022  12:00:00 AM
azu03                              1               3/11/2022  11:00:00 PM         3/12/2022  12:00:00 AM
azu04                              1               3/11/2022  11:00:00 PM         3/12/2022  12:00:00 AM

Get-Date

Friday, March 11, 2022 11:53:41 PM

New-BrokerHostingPowerAction -Action "Restart" -MachineName azu01

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil
------       -------------------------  ---------------------------------  -----------------------------
azu01                              2  
azu02                              1               3/11/2022  11:00:00 PM         3/12/2022  12:00:00 AM
azu03                              1               3/11/2022  11:00:00 PM         3/12/2022  12:00:00 AM
azu04                              1               3/11/2022  11:00:00 PM         3/12/2022  12:00:00 AM
<!--NeedCopy-->

EXAMPLE 2

Set azu01 and azu02 in azure-catalog to have a property update anytime from 11pm EST (-4) until 2 days later. The other machines remain having no property update time window set. Times for ProvisioningSchemeUpdateRequested and ProvisioningSchemeUpdateUntil are displayed in local time (EST in this case). The update will be run next time each machine boots in that window.

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil
------       -------------------------  ---------------------------------  -----------------------------
azu01                              1    
azu02                              1   
azu03                              1   
azu04                              1  

$duration = New-TimeSpan -Days 2

Set-ProvVMUpdateTimeWindow -ProvisioningSchemeName azure-catalog -VMName azu01, azu02 -StartTimeInUTC "3/11/2022 11pm -4" -DurationInMinutes $duration.TotalMinutes

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil
------       -------------------------  ---------------------------------  -----------------------------
azu01                              1               3/11/2022  11:00:00 PM         3/13/2022  11:00:00 PM
azu02                              1               3/11/2022  11:00:00 PM         3/13/2022  11:00:00 PM
azu03                              1
azu04                              1
<!--NeedCopy-->

EXAMPLE 3

Set azu01 and azu02 in azure-catalog to have a property update anytime after 7 days from now. The other machines remain having no property update time window set. The update will be run next time each machine boots after the start time.

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil
------       -------------------------  ---------------------------------  -----------------------------
azu01                              1    
azu02                              1   
azu03                              1   
azu04                              1  

$startTime = (Get-Date).AddDays(7).ToUniversalTime()

Set-ProvVMUpdateTimeWindow -ProvisioningSchemeName azure-catalog -VMName azu01, azu02 -StartTimeInUTC $startTime -DurationInMinutes -1

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil
------       -------------------------  ---------------------------------  -----------------------------
azu01                              1               3/18/2022  11:32:51 PM  
azu02                              1               3/18/2022  11:32:51 PM 
azu03                              1
azu04                              1
<!--NeedCopy-->

EXAMPLE 4

Set azu01 and azu02 in azure-catalog to have a property update when next booted. The other machines remain having no property update time window set.

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil
------       -------------------------  ---------------------------------  -----------------------------
azu01                              1    
azu02                              1   
azu03                              1   
azu04                              1  

Set-ProvVMUpdateTimeWindow -ProvisioningSchemeName azure-catalog -VMName azu01, azu02 -StartsNow  -DurationInMinutes -1

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil
------       -------------------------  ---------------------------------  -----------------------------
azu01                              1               3/11/2022  11:32:51 PM 
azu02                              1               3/11/2022  11:32:51 PM 
azu03                              1
azu04                              1
<!--NeedCopy-->

EXAMPLE 5

Change the MachineProfile for the azure-catalog provisioning scheme with Set-ProvScheme, this increments the provisioning scheme version to 2. Configure a custom service offering for azu01. Set all 4 VMs in azure-catalog to have a property update in the time window starting now and lasting for 60 minutes. Times for ProvisioningSchemeUpdateRequested and ProvisioningSchemeUpdateUntil are displayed in local time (EST in this case). Rebooting azu01 applies both the pending configuration and provisioning scheme updates. Rebooting azu02 applies the pending provisioning scheme update

Set-ProvScheme -ProvisioningSchemeName azure-catalog -MachineProfile "XDHyp:\HostingUnits\azure-unit\machineprofile.folder\new-template.vm"

Get-ProvScheme | select ProvisioningSchemeName, ProvisioningSchemeVersion
ProvisioningSchemeName   ProvisioningSchemeVersion
-----------------------  --------------------------
azure-catalog                                     2

Set-ProvVM -ProvisioningSchemeName azure-catalog -VMName azu01 -ServiceOffering "XDHyp:\HostingUnits\azure-unit\"

Get-ProvVMConfiguration
CpuCount               : 
CustomProperties       : 
MachineProfile         :
MemoryInMB             :
ProvisioningSchemeName : azure-catalog
ProvisioningSchemeUid  : 378cece5-a824-41f7-9e92-74be76672be6
ServiceOffering        : serviceoffering.folder\Standard_D2s_v3.serviceoffering
VMId                   : 0707da6d-2f0f-a8c7-ce92-3d64f824ac60
VMMetadata             :
VMName                 : azu01
Version                : 1


Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil, ProvVMConfigurationVersion
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil  ProvVMConfigurationVersion
------       -------------------------  ---------------------------------  -----------------------------  --------------------
azu01                              1                                                                                         
azu02                              1   
azu03                              1   
azu04                              1  

Set-ProvVMUpdateTimeWindow -ProvisioningSchemeName azure-catalog -StartsNow -DurationInMinutes 60

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil, ProvVMConfigurationVersion
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil  ProvVMConfigurationVersion
------       -------------------------  ---------------------------------  -----------------------------  --------------------
azu01                              1               3/11/2022  10:37:14 PM         3/11/2022 11:37:14 PM
azu02                              1               3/11/2022  10:37:14 PM         3/11/2022 11:37:14 PM
azu03                              1               3/11/2022  10:37:14 PM         3/11/2022 11:37:14 PM
azu04                              1               3/11/2022  10:37:14 PM         3/11/2022 11:37:14 PM

New-BrokerHostingPowerAction -Action "Restart" -MachineName azu01

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil, ProvVMConfigurationVersion
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil  ProvVMConfigurationVersion
------       -------------------------  ---------------------------------  -----------------------------  --------------------
azu01                              2                                                                                         1
azu02                              1               3/11/2022  10:37:14 PM         3/11/2022 11:37:14 PM
azu03                              1               3/11/2022  10:37:14 PM         3/11/2022 11:37:14 PM
azu04                              1               3/11/2022  10:37:14 PM         3/11/2022 11:37:14 PM

New-BrokerHostingPowerAction -Action "Restart" -MachineName azu02

Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil, ProvVMConfigurationVersion
VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil  ProvVMConfigurationVersion
------       -------------------------  ---------------------------------  -----------------------------  --------------------
azu01                              2                                                                                         1
azu02                              2
azu03                              1               3/11/2022  10:37:14 PM         3/11/2022 11:37:14 PM
azu04                              1               3/11/2022  10:37:14 PM         3/11/2022 11:37:14 PM
<!--NeedCopy-->

Parameters

-ProvisioningSchemeName

The name of the provisioning scheme

Type: String
Position: Named
Default value: None
Required: True
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
Type: String
Position: Named
Default value: None
Required: True
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-VMName

List of VM names set a time window for. If not specified, all VMs in the machine catalog associated with the specified provisioning scheme will have the time window applied

Type: String[]
Position: Named
Default value: None
Required: True
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-ProvisioningSchemeUid

The unique identifier of the provisioning scheme

Type: Guid
Position: Named
Default value: None
Required: True
Accept pipeline input: False
Accept wildcard characters: False

-StartTimeInUTC

The start time in UTC format of the time window. Mutually exclusive with StartsNow switch. Must be no more than 5 seconds in the past. The given string will be converted into a DateTime using parsing rules defined by the DateTime.Parse method, which allows for a timezone offset to specify time in any timezone. If no timezone offset is specified, UTC will be assumed. See the example usages of Set-ProvVMUpdateTimeWindow or this link for more details https://docs.microsoft.com/en-us/dotnet/api/system.datetime.parse?view=net-6.0#the-string-to-parse

Type: String
Position: Named
Default value: None
Required: False
Accept pipeline input: False
Accept wildcard characters: False

-StartsNow

Whether this time window should start right away at the current time. Mutually exclusive with specific StartTimeInUTC. Implied to be set if StartTimeInUTC is not specified

Type: SwitchParameter
Position: Named
Default value: None
Required: False
Accept pipeline input: False
Accept wildcard characters: False

-DurationInMinutes

The duration in minutes of the time window. If less than 0, indicates the time window has no upper bound

Type: Int32
Position: Named
Default value: 120 minutes
Required: False
Accept pipeline input: False
Accept wildcard characters: False

-LoggingId

Specifies the identifier of the high-level operation this cmdlet call forms a part of. Citrix Studio and Director typically create high-level operations. PowerShell scripts can also wrap a series of cmdlet calls in a high-level operation by way of the Start-LogHighLevelOperation and Stop-LogHighLevelOperation cmdlets.

Type: Guid
Position: Named
Default value: None
Required: False
Accept pipeline input: False
Accept wildcard characters: False

CitrixCommonParameters

This cmdlet supports the common Citrix parameters: -AdminAddress, -AdminClientIP, -BearerToken, -TraceParent, -TraceState and -VirtualSiteId. For more information, see about_CitrixCommonParameters.

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

Citrix.MachineCreation.Sdk.ProvisionedVirtualMachine

You can pipe an object containing parameters called ‘VMId’ and ‘ProvisioningSchemeName’ to Set-ProvVMUpdateTimeWindow.

Outputs

None

By default, this cmdlet returns no output.

Notes

In the case of failure, the following errors can result.

Error Codes


ProvisioningSchemeNotFound

The specified provisioning scheme could not be located.

ProvisioningSchemeNotReady

The specified provisioning scheme is not in Ready state.

Set-ProvVMUpdateTimeWindow