Citrix Virtual Apps and Desktops SDK

New-ProvImageVersion

Prepare an image version in one image definition which can be used by provisioning scheme to provisioning virtual machines.

Syntax

New-ProvImageVersion
   -MasterImageVM <String>
   [-PreparedImageVersionNumber] <String>
   -PreparedImageDefinitionName <String>
   -PreparedImageSchemeName <String>
   [-Description <String>]
   [-NoImagePreparation]
   [-WriteBackCacheDiskSize <Int32>]
   [-WriteBackCacheMemorySize <Int32>]
   [-Metadata <Hashtable>]
   [-RunAsynchronously]
   [-PurgeJobOnSuccess]
   [-LoggingId <Guid>]
   [<CitrixCommonParameters>]
   [<CommonParameters>]
<!--NeedCopy-->
New-ProvImageVersion
   -MasterImageVM <String>
   [-PreparedImageVersionNumber] <String>
   -PreparedImageDefinitionUid <Guid>
   -PreparedImageSchemeUid <Guid>
   [-Description <String>]
   [-NoImagePreparation]
   [-WriteBackCacheDiskSize <Int32>]
   [-WriteBackCacheMemorySize <Int32>]
   [-Metadata <Hashtable>]
   [-RunAsynchronously]
   [-PurgeJobOnSuccess]
   [-LoggingId <Guid>]
   [<CitrixCommonParameters>]
   [<CommonParameters>]
<!--NeedCopy-->

Description

The prepared image version can be assigned to provisioning schemes to provision virtual machines

A snapshot is used rather than a VM, so that the content of the hard disk for the image scheme can be easily determined.

As the snapshot is specified using a path into the Citrix Host Service Powershell Provider, the Citrix Host Service Powershell snap-in must also be loaded for this cmdlet to be used.

Examples

EXAMPLE 1

Prepares a new master hard disk image for the myImage version 1 using the “base.snapshot” hard disk image.

New-ProvImageVersion -PreparedImageVersionNumber 1 -PreparedImageDefinitionName myImage -PreparedImageSchemeName myImageScheme -MasterImageVM XDHyp:\H
  stingUnits\HostUnit1\RhoneCC_baseXP.vm\base.snapshot -RunAsynchronously

  Guid
  ----
  0828571f-d6c2-4795-bd47-7e58b6586f34

  c:\PS>get-provtask -TaskId 0828571f-d6c2-4795-bd47-7e58b6586f34
  TaskId                     : 0828571f-d6c2-4795-bd47-7e58b6586f34
  Active                     : True
  Host                       : E70972-42-1
  DateStarted                : 4/2/2022 2:57:21 AM
  Metadata                   : {}
  Type                       : NewImageVersion
  Status                     : Running
  CurrentOperation           : PreparingMasterImage
  TaskExpectedCompletion     :
  LastUpdateTime             : 4/2/2022 2:57:42 AM
  ActiveElapsedTime          : 21
  DateFinished               :
  TerminatingError           :
  Storage                    : {}
  WorkflowStatus             : Running
  Warnings                   : {}
  ImageStatus                :
  PreparedImageVersionNumber : 1
  PreparedImageVersionUid    : b1c7602c-b080-4a63-846b-9d2429d54bd1
  PreparedImageDefinitionName: myImage
  PreparedImageDefinitionUid : 42bd09f5-3fac-44a6-8b1c-7c09f1079cc0
  PreparedImageSchemeName    : myImageScheme
  PreparedImageSchemeUid     : 53ed79c3-c771-4114-ba05-b999a62a836f
  HostingUnitUid             : 0be23759-e276-4657-b863-e958a716cb6e
  CustomProperties           :
  AdditionalCustomProperties :
  InitialBatchSizeHint       : 1
  TaskState                  : ImagePreparationInitialization
  TaskStateInformation       : ImageDefinitionName:/East US.region/image.folder/hu.resourcegroup/vda-snapshot.snapshot, StoragePath:, HostingUnitName:hu
  TaskProgress               :
  WriteBackCacheDiskSize     : 0
  WriteBackCacheMemorySize   : 0
  Scopes                     : ??
  NetworkMaps                : {0}
  ServiceOffering            : serviceoffering.folder\Standard_B2ms.serviceoffering
  StatusMessageSubstitutions :
<!--NeedCopy-->

Parameters

-PreparedImageVersionNumber

The version number of the image version to be created.

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

-MasterImageVM

The path in the hosting unit provider to the virtual machine snapshot that will be used. This identifies the hard disk to be used and the default values for the memory and processors. This must be a path to a Snapshot item in the same hosting unit that the hosting unit name or hosting unit Uid refers to.

Valid paths are of the format; XDHyp:\HostingUnits\<HostingUnitName>\<path>\<VMName>.vm\<SnapshotName>.snapshot

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

-PreparedImageDefinitionName

The name for the image definition used for the image version.

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

-PreparedImageSchemeName

The name for the image scheme used for the image version.

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

-PreparedImageDefinitionUid

The identifier for the image definition used for the image version.

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

-PreparedImageSchemeUid

The identifier for the image scheme used for the image version.

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

-Description

A value indicating the image version description.

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

-NoImagePreparation

Gets or sets a flag indicating that Image Preparation should be disabled

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

-WriteBackCacheDiskSize

The size in GB of any temporary storage disk used by the write back cache. Should be used in conjunction with WriteBackCacheMemorySize.

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

-WriteBackCacheMemorySize

The size in MB of any write back cache if required. Should be used in conjunction with WriteBackCacheDiskSize. Setting RAM Cache to 0 but specifying Disk Cache effectively disables the RAM Cache. However, there will be some memory still used to allow the I/O Optimization to operate.

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

-Metadata

Gets or sets metadata of the image version.

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

-RunAsynchronously

Indicates whether or not the cmdlet should return before it is complete. If specified, the command returns an identifier for the task that was created. You can monitor this task using the Get-ProvTask cmdlet.

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

-PurgeJobOnSuccess

Indicates that the task history will be removed from the database when the task has finished. This cannot be specified for tasks that are run asynchronously.

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

Active <Boolean>

Indicates whether the task is still processing or is complete.

Host <string>

The name of the host on which the task is running or was run.

Type <Citrix.XDInterServiceTypes.JobType>

The type of the task. For new image version tasks this is always “NewImageVersion”.

Status <string>

Where in its lifecycle the task is.

CurrentOperation <string>

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

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.

Storage <Citrix.MachineCreation.Sdk.NewProvSchemeStorage[]>

Storage objects to be used for the new image version task.

Warnings <Citrix.MachineCreation.Sdk.ProvSchemeWarning[]>

Warnings associated with the new image version task.

WorkflowStatus <System.Workflow.Runtime.WorkflowStatus>

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

PreparedImageVersionNumber <string>

The version number of the image versions that the task was for.

PreparedImageVersionUid <Guid>

The unique identifier of the image version that the task was for.

PreparedImageDefinitionName <string>

The name of the image definition for which the image version is created.

PreparedImageDefinitionUid <Guid>

The unique identifier of the image definition that the task was for.

PreparedImageSchemeUid <Guid>

The unique identifier of the image scheme which is used for this image version.

MasterImage <string>

The path (in the hosting unit provider) of the virtual machine snapshot that was used as the master image for the task.

Metadata <System.Collections.Generic.Dictionary[string, string];>

The metadata to apply to the image version, if specified.

CustomProperties <string>

The properties of the image version that are specific to the target hosting infrastructure.

InitialBatchSizeHint <int>

The number of VMs that are expected to be added to the scheme as an initial batch.

HostingUnitUid <Guid>

The unique identifier of the hosting unit (from the Hosting Unit PowerShell snap-in) that the new image version will use.

TaskState <Citrix.DesktopUpdateManager.SDK.NewProvisioningSchemeState>

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

Processing

Indicates that the task has just begun and has not done anything yet.

LocatingResources,

Indicates that the workflow is locating resources from other services.

HostingUnitNotFound

Indicates that the task failed because the required hosting unit could not be located.

VirtualMachineSnapshotNotFound

Indicates that the task failed because the required snapshot could not be located.

ConsolidatingMasterImage

Indicates that the task is consolidating the master image.

ReplicatingConsolidatedImageToAllStorage

Indicates that the task is replicating the consolidated master image.

StoringImageVersion

Indicates that the task is storing the image version data to the database.

Finished

Indicates that the task has completed with no errors.

ImageVersionAlreadyExists

Indicates that the task failed because a image version with the same name already exists.

MasterVMImageIsNotPartOfImageDefinitionHostingUnit,

Indicates that the hosting unit that the master image originated from is not the hosting unit that the image definition is defined to use.

MasterVmImageIsNotASnapshot

Indicates that the task failed because the master VM Image path does not refer to a Snapshot item.

InvalidMasterVMConfiguration

The VM snapshot specified as the master had an invalid configuration.

InvalidMasterVMState

The VM snapshot specified as the master is currently in an invalid state.

InsufficientResources

Indicates that the task failed because the hypervisor did not have enough resources to complete the task.

StorageNotFound

Indicates that no associated storage was found in the hosting unit.

Canceled

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

TaskStateInformation <string>

Holds string data providing more details about the current task state.

TaskProgress

The progress of the task 0-100%.

WriteBackCacheDiskSize <int>

The size of any write-back cache disk (zero if the write-back cache feature was not selected).

WriteBackCacheMemorySize <int>

The size of the write-back cache (zero if the write-back cache feature was not selected).

NetworkMaps <Citrix.MachineCreation.Sdk.NetworkMap[]>

The list of NIC to network associations, if specified.

ServiceOffering <string>

The service offering that the scheme uses when creating VMs in Cloud Hypervisors.

Notes

Only one long-running task per image version can be processed at any one 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

for various reasons.

WorkflowHostUnavailable

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

CommunicationError

An error occurred while communicating with the service.

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.

ExceptionThrown

An unexpected error occurred. To locate more details, see the Windows event logs on the controller being used or examine the XenDesktop logs.

UnsupportedByServer

The requested operation is not supported by this version of the service.

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

ValidatingInputs

ConsolidatingMasterImage

PreparingMasterImage

ReplicatingMasterImage

CommittingScheme

New-ProvImageVersion