Citrix Virtual Apps and Desktops SDK

New-ProvVMSnapshot

Introduced in: Citrix Virtual Apps and Desktop 7 2407

Creates new provsioned snapshots for a virtual machine.

Syntax

New-ProvVMSnapshot
   -ProvisioningSchemeUid <Guid>
   [-VMName <String[]>]
   [-SnapshotNamingScheme <String>]
   [-DeletionProtected]
   [-UserVisible]
   [-Immediate]
   [-RunAsynchronously]
   [-PurgeJobOnSuccess]
   [-LoggingId <Guid>]
   [<CitrixCommonParameters>]
   [<CommonParameters>]
<!--NeedCopy-->
New-ProvVMSnapshot
   -ProvisioningSchemeName <String>
   [-VMName <String[]>]
   [-SnapshotNamingScheme <String>]
   [-DeletionProtected]
   [-UserVisible]
   [-Immediate]
   [-RunAsynchronously]
   [-PurgeJobOnSuccess]
   [-LoggingId <Guid>]
   [<CitrixCommonParameters>]
   [<CommonParameters>]
<!--NeedCopy-->

Description

Lets you create new snapshots of virtual machines, including the boot disk and hardware attributes. The machine must be created by MCS and persistent.

Examples

EXAMPLE 1

Creates snapshots based on the virtual machines in the provisioning scheme “MyScheme”.

New-ProvVMSnapshot -ProvisioningSchemeName MyScheme

TaskId                             : 90e93b9d-a225-4701-ad50-fa1546af35ac
Type                               : NewSnapshot
Status                             : Finished
CurrentOperation                   :
TaskProgress                       : 100
TaskExpectedCompletion             :
LastUpdateTime                     : 17/05/2020 08:24:08
ActiveElapsedTime                  : 11
DateStarted                        : 17/05/2020 08:22:22
DateFinished                       : 17/05/2020 08:24:08
TerminatingError                   :
WorkflowStatus                     : Completed
ProvisioningSchemeName             : MyScheme
StatusMessageSubstitutions         : {}
ProvisioningSchemeUid              : 7585f0de-192e-4847-a6d8-22713c3a2f42
TaskState                          : Finished
TaskStateInformation               :
HostingUnitUid                     : 01a4a008-8ce8-4165-ba9c-cdf15a6b0501
HostingUnitName                    : XenHU
VirtualMachinesToCreateCount       : 10
VirtualMachinesCreatedCount        : 10
VirtualMachinesCreationFailedCount : 0
CreatedVirtualMachines             : {...}
FailedVirtualMachines              : {}
<!--NeedCopy-->

EXAMPLE 2

Creates snapshots from virtual machines “vm01”, “vm02”, and “vm03” in the provisioning scheme “MyScheme”.

New-ProvVMSnapshot -ProvisioningSchemeName MyScheme -VMNames vm01,vm02,vm03

TaskId                             : 587717c5-4763-41e1-80c6-1d1fb32fa1fd
Type                               : NewSnapshot
Status                             : Finished
CurrentOperation                   :
TaskProgress                       : 100
TaskExpectedCompletion             :
LastUpdateTime                     : 17/10/2022 08:24:08
ActiveElapsedTime                  : 11
DateStarted                        : 17/10/2022 08:22:22
DateFinished                       : 17/10/2022 08:24:08
TerminatingError                   :
WorkflowStatus                     : Completed
ProvisioningSchemeName             : MyScheme
StatusMessageSubstitutions         : {}
ProvisioningSchemeUid              : 7585f0de-192e-4847-a6d8-22713c3a2f42
TaskState                          : Finished
TaskStateInformation               :
HostingUnitUid                     : 01a4a008-8ce8-4165-ba9c-cdf15a6b0501
HostingUnitName                    : XenHU
VirtualMachinesToCreateCount       : 3
VirtualMachinesCreatedCount        : 3
VirtualMachinesCreationFailedCount : 0
CreatedVirtualMachines             : {...}
FailedVirtualMachines              : {}
<!--NeedCopy-->

EXAMPLE 3

Creates snapshots with deletion protection enabled based on the virtual machines in the provisioning scheme “MyScheme” asynchronously. To get the task details, use Get-ProvTask -TaskID <task id> .

New-ProvVMSnapshot -ProvisioningSchemeName MyScheme -RunAsynchronously -DeletionProtected

Guid
----
6dd85fec-96cf-46b1-9cd4-d8ba7d06e85b

Get-ProvTask -TaskID 6dd85fec-96cf-46b1-9cd4-d8ba7d06e85b

TaskId                             : 4b49f13a-277c-4cb0-bc40-f088430cfe8a
Type                               : NewSnapshot
Status                             : Finished
CurrentOperation                   :
TaskProgress                       : 100
TaskExpectedCompletion             :
LastUpdateTime                     : 17/05/2020 08:24:08
ActiveElapsedTime                  : 11
DateStarted                        : 17/05/2020 08:22:22
DateFinished                       : 17/05/2020 08:24:08
TerminatingError                   :
WorkflowStatus                     : Completed
ProvisioningSchemeName             : MyScheme
StatusMessageSubstitutions         : {}
ProvisioningSchemeUid              : 7585f0de-192e-4847-a6d8-22713c3a2f42
TaskState                          : Finished
TaskStateInformation               :
HostingUnitUid                     : 01a4a008-8ce8-4165-ba9c-cdf15a6b0501
HostingUnitName                    : XenHU
VirtualMachinesToCreateCount       : 10
VirtualMachinesCreatedCount        : 10
VirtualMachinesCreationFailedCount : 0
CreatedVirtualMachines             : {...}
FailedVirtualMachines              : {}
<!--NeedCopy-->

Parameters

-ProvisioningSchemeName

The name of the provisioning scheme for the VMs.

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

-ProvisioningSchemeUid

The unique identifier of the provisioning scheme for the VMs.

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

-VMName

The names of the VMs to create snapshots from.

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

-SnapshotNamingScheme

The naming scheme to use for each of the created snapshots. The name must be unique relative to other provisioned snapshots for the targeted virtual machine. Certain snapshot and machine properties can be baked in using the form ‘{PropertyName}’. These properties include:

  • For the Provisioned Snapshot:
  • CreationUTCDateTime
  • SnapshotVersion
  • SnapshotStatus
  • SnapshotUid
  • For the Provisioned Virtual Machine:
  • VMId
  • VMName
  • ProvVMConfigurationVersion
  • ProvisioningSchemeVersion
  • ADAccountName
Type: String
Position: Named
Default value: {VMName}-sn-{SnapshotUid}
Required: False
Accept pipeline input: False
Accept wildcard characters: False

-DeletionProtected

Indicates if the snapshot should require explicit deletion.

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

-UserVisible

Sets whether the snapshot is visible to users.

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

-Immediate

*REQUIRED* Indicates to immediately create snapshots instead of scheduling during next machine maintenance cycle.

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

-RunAsynchronously

Indicates whether the command returns before it completes. If specified, the command returns an identifier for the task that was created. This task can be monitored using the Get-ProvTask command.

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

-PurgeJobOnSuccess

Indicates that the task history is removed from the database when the task completes. This cannot be specified for tasks that run asynchronously.

Type: SwitchParameter
Position: Named
Default value: None
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

None

You can’t pipe objects to this cmdlet.

Outputs

Guid

When the RunAsynchronously identifier is specified, this GUID is returned and provides the task identifier.

System.Management.Automation.PSCustomObject

This object provides details of the task that was run and contains the following information:

TaskId <Guid>

The identifier for the task that was performed.

Type <Citrix.XDInterServiceTypes.JobType>

The type of task. For provisioning new VM tasks, this is always “NewVirtualMachine”.

Status <string>

Where in its lifecycle the task is.

CurrentOperation <string>

Operation specific phase of the overall “Running” task state.

TaskProgress <double>

The progress of the task 0-100%.

TaskExpectedCompletion <DateTime>

The date and time at which the task is expected to complete.

LastUpdateTime <DateTime>

The date and time of the last task status update.

ActiveElapsedTime <int>

Number of seconds the task has taken for active execution.

DateStarted <DateTime>

The date and time when the task was started.

DateFinished <DateTime>

The date and time when the task was completed.

TerminatingError < Citrix.Fma.Sdk.ServiceCore.CommonCmdlets.TaskterminatingError>

Diagnostic information if the task completely fails.

WorkflowStatus <System.Workflow.Runtime.WorkflowStatus>

Indicates the status of the workflow that is used to process the task.

ProvisioningSchemeName <string>

The name of the provisioning scheme associated with the task.

StatusMessageSubstitutions <string[]>

List of strings to be substituted into custom error or status messages from provisioning plug-ins.

ProvisioningSchemeUid <Guid>

The unique identifier of the provisioning scheme associated with the task.

TaskState <Citrix.DesktopUpdateManager.SDK.ProvisionVMState>

The state of the task. This can be any of the following:

Processing

Indicates that the task is in its initial state.

LocatingResources,

Indicates that the task is locating information from other services.

HostingUnitNotFound

Indicates that the required hosting unit could not be located.

ProvisioningSchemeNotFound

Indicates that the required provisioning scheme could not be located.

Provisioning

Indicates that the task is at the provisioning stage.

IdentityPoolNotFound

Indicates that the required identity pool could not be located.

TaskAlreadyRunningForProvisioningScheme

Indicates that the provisioning scheme already has another task running.

HypervisorInMaintenanceMode

Indicates that the hypervisor is not available for normal use.

NoAvailableStorage

Indicates that no storage is available for the hypervisor.

NoAvailableNetwork

Indicates that no network is available for the hypervisor.

Finalizing

Indicates that the task is finalizing.

Finished

Indicates that the task is complete.

FinishedWithErrors

Indicates that the task is complete but there were errors. Specific details of errors are included with each failed snapshot.

Removing

Indicates that the task is removing snapshots from the hypervisor.

Failed

The job failed for reasons specified in TaskStateInformation.

Canceled

Indicates that the task was stopped by user intervention (using Stop-ProvTask).

TaskStateInformation

Provides more detailed information about the current task state.

HostingUnitUid

The unique identifier of the hosting unit that is used by the provisioning task.

HostingUnitName <string>

The name of the hosting unit that is used by the provisioning task.

SnapshotsToCreateCount <int>

The total number of snapshots that the task is trying to create.

SnapshotsCreatedCount <int>

The number of snapshots that the task has created so far. Details of the machines that were created are in the CreatedSnapshots parameter.

SnapshotsCreationFailedCount <int>

The number of snapshots that the task has failed to create. Details of the machines that were not created are in the FailedSnapshots parameter.

CreatedSnapshots <Citrix.DesktopUpdateManager.SDK.ProvisionedSnapshot[]>

Object array of created snapshots summary information. The object properties are:

CreationDate <DateTime>

The date and time when the snapshot was created.

Domain <string>

The Domain of the AD computer account that the VM is using.

ProvisioningSchemeName <string>

The name of the provisioning scheme associated with the snapshot.

ProvisioningSchemeUid <Guid>

The unique identifier of the provisioning scheme associated with the snapshot.

ProvisioningSchemeVersion <int>

The version of the provisioning scheme used by the associated VM at the time of snapshot creation.

ProvVMConfigurationVersion <int>

The version of the custom configuration used by the associated VM at the time of snapshot creation.

SnapshotUid <Guid>

The unique identifier of the provisioned snapshot.

HypervisorID<string>

The hypervisor identifier of the provisioned snapshot.

SnapshotName <string>

The name of the provisioned snapshot.

VMId <string>

The identifier for the associated VM in the hypervisor.

VMName <string>

The name of the associated VM in the hypervisor.

HostingUnitUid <Guid>

The unique identifier of the hosting unit that was used to create the associated VM.

HypervisorConnectionUid <Guid>

The unique identifier of the hypervisor connection that was used to create the associated VM.

DeletionProtection <bool>

Flag indicating if snapshot requires explicit deletion.

FailedSnapshots <Citrix.DesktopUpdateManager.SDK.ProvisionedSnapshot[]>

See CreatedSnapshots for details of the object parameters.

Notes

The cmdlet is associated with a task of type NewSnapshot, and while active will move through the following operations (CurrentOperation field)

ValidatingInputs

CreatingSnapshots

Only one long-running task in each provisioning scheme can be processed at a time.

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

Error Codes


JobCreationFailed

The requested task could not be started.

DatabaseError

An error occurred in the service while attempting a database operation.

DatabaseNotConfigured

The operation could not be completed because the database for the service is not configured.

ServiceStatusInvalidDb

An error occurred in the service while attempting a database operation. Communication with the database failed

for various reasons.

WorkflowHostUnavailable

The task could not be started because the database connection is inactive.

PermissionDenied

The user does not have administrative rights to perform this operation.

ConfigurationLoggingError

The operation could not be performed because of a configuration logging error

CommunicationError

An error occurred while communicating with the service.

InvalidParameterCombination

Both PurgeJobOnSuccess and RunAsynchronously were specified.

When running asynchronously, the cmdlet terminates before the job does,

so it cannot clean up the completed job.

PermissionDenied

The user does not have administrative rights to perform this operation.

ExceptionThrown

An unexpected error occurred. For more details, see the Windows event logs

on the controller being used, or Citrix Virtual Apps and Desktops logs.

New-ProvVMSnapshot