Citrix Virtual Apps and Desktops SDK

Set-ProvVMUpdateTimeWindow

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

Syntax


Set-ProvVMUpdateTimeWindow -ProvisioningSchemeName <String> [-StartTimeInUTC <String>] [-StartsNow] [-DurationInMinutes <Int32>] [-LoggingId <Guid>] [-BearerToken <String>] [-AdminClientIP <String>] [-TraceParent <String>] [-TraceState <String>] [-VirtualSiteId <String>] [-AdminAddress <String>] [<CommonParameters>]

Set-ProvVMUpdateTimeWindow -ProvisioningSchemeName <String> -VMName <String[]> [-StartTimeInUTC <String>] [-StartsNow] [-DurationInMinutes <Int32>] [-LoggingId <Guid>] [-BearerToken <String>] [-AdminClientIP <String>] [-TraceParent <String>] [-TraceState <String>] [-VirtualSiteId <String>] [-AdminAddress <String>] [<CommonParameters>]

Set-ProvVMUpdateTimeWindow -ProvisioningSchemeUid <Guid> [-StartTimeInUTC <String>] [-StartsNow] [-DurationInMinutes <Int32>] [-LoggingId <Guid>] [-BearerToken <String>] [-AdminClientIP <String>] [-TraceParent <String>] [-TraceState <String>] [-VirtualSiteId <String>] [-AdminAddress <String>] [<CommonParameters>]

Set-ProvVMUpdateTimeWindow -ProvisioningSchemeUid <Guid> -VMName <String[]> [-StartTimeInUTC <String>] [-StartsNow] [-DurationInMinutes <Int32>] [-LoggingId <Guid>] [-BearerToken <String>] [-AdminClientIP <String>] [-TraceParent <String>] [-TraceState <String>] [-VirtualSiteId <String>] [-AdminAddress <String>] [<CommonParameters>]

<!--NeedCopy-->

Detailed Description

Provides the ability to synchronize the properties of existing virtual machines with any changes occurred on the provisioning scheme.

This cmdlet defines a time window where a provisioning scheme 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.

Parameters

Name Description Required? Pipeline Input Default Value
ProvisioningSchemeName The name of the provisioning scheme true true (ByValue, ByPropertyName)  
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 true true (ByValue, ByPropertyName)  
ProvisioningSchemeUid The unique identifier of the provisioning scheme true 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 false 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 false false  
DurationInMinutes The duration in minutes of the time window. If less than 0, indicates the time window has no upper bound false false 120 minutes
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. false false  
BearerToken Specifies the bearer token assigned to the calling user false false  
AdminClientIP Specifies the Client IP of the calling user false false  
TraceParent Specifies the trace parent assigned for internal diagnostic tracing use false false  
TraceState Specifies the trace state assigned for internal diagnostic tracing user false false  
VirtualSiteId Specifies the virtual site the PowerShell snap-in will connect to. false false  
AdminAddress The address of a Citrix Virtual Apps and Desktops controller the PowerShell snap-in will connect to. You can provide this as a host name or an IP address. false false Localhost. Once a value is provided by any cmdlet, this value becomes the default.

Input Type

Citrix.Machinecreation.Sdk.Provisionedvirtualmachine

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

Return Values

Examples

Example 1


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

c:\PS> Get-ProvScheme | select ProvisioningSchemeName, ProvisioningSchemeVersion

ProvisioningSchemeName   ProvisioningSchemeVersion

-----------------------  --------------------------

azure-catalog                                     2

c:\PS> Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil

VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil

------       -------------------------  ---------------------------------  -----------------------------

azu01                              1

azu02                              1

azu03                              1

azu04                              1

c:\PS> Set-ProvVMUpdateTimeWindow -ProvisioningSchemeName azure-catalog -StartTimeInUTC "3/12/2022 3am" -DurationInMinutes 60

c:\PS> 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

c:\PS> Get-Date

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

c:\PS> New-BrokerHostingPowerAction -Action "Restart" -MachineName azu01

c:\PS> 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

c:\PS> Get-Date

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

c:\PS> New-BrokerHostingPowerAction -Action "Restart" -MachineName azu01

c:\PS> 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-->

Description

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.

Example 2


c:\PS> Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil

VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil

------       -------------------------  ---------------------------------  -----------------------------

azu01                              1

azu02                              1

azu03                              1

azu04                              1

c:\PS> $duration = New-TimeSpan -Days 2

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

c:\PS> 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-->

Description

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.

Example 3


c:\PS> Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil

VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil

------       -------------------------  ---------------------------------  -----------------------------

azu01                              1

azu02                              1

azu03                              1

azu04                              1

c:\PS> $startTime = (Get-Date).AddDays(7).ToUniversalTime()

c:\PS> Set-ProvVMUpdateTimeWindow -ProvisioningSchemeName azure-catalog -VMName azu01, azu02 -StartTimeInUTC $startTime -DurationInMinutes -1

c:\PS> 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-->

Description

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.

Example 4


c:\PS> Get-ProvVM | select VMName, ProvisioningSchemeVersion, ProvisioningSchemeUpdateRequested, ProvisioningSchemeUpdateUntil

VMName       ProvisioningSchemeVersion  ProvisioningSchemeUpdateRequested  ProvisioningSchemeUpdateUntil

------       -------------------------  ---------------------------------  -----------------------------

azu01                              1

azu02                              1

azu03                              1

azu04                              1

c:\PS> Set-ProvVMUpdateTimeWindow -ProvisioningSchemeName azure-catalog -VMName azu01, azu02 -StartsNow  -DurationInMinutes -1

c:\PS> 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-->

Description

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.

Set-ProvVMUpdateTimeWindow