Scripting Citrix Provisioning Services (PVS) with PowerShell and Command Line

In the Ultimate Golden Image Automation Guide I wrote about creating a new Citrix Provisioning vDisk with MCLI command line. But you can of course also do this with PowerShell and there are a lot more commands to use. So in this blog I will show the most popular Citrix Provisioning commands in MCLI command line and PowerShell. I hope this will help you to script / automate your deployments and workflow. Because as always, automate EVERYTHING !!

*To use the PowerShell commands you first need to load the PVS PowerShell module: Import-Module “C:\Program Files\Citrix\Provisioning Services Console\Citrix.PVS.SnapIn.dll”

Jump to command:

Create a new vDisk:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” RunWithReturn CreateDisk -p Name=DiskName Size=SizeInMB Storename=YourStoreName ServerName=YourPVSServerName Sitename=YourSiteName Format=1 Type=1

Format 1 is VHDX 0 is VHD | Type 1 is Dynamic 0 is Fixed

PowerShell

Start-PVSCreateDisk -Name ““YourDiskName” -Size “SizeInMB” -StoreName “YourStoreName” -ServerName “YourPVSServerName” -SiteName “YourSiteName” -VHDX

Back to jump list.

Add an existing vDisk to PVS Store:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” add disklocator -r disklocatorNameYourDiskName sitename=YourSiteName storename=YourStoreName serverName=YourPVSServerName format=1

Format 1 is VHDX 0 is VHD

PowerShell

New-PvsDiskLocator -Name “YourDiskName” -StoreName “YourStoreName” -ServerName “YourPVSServerName” -SiteName “YourSiteName” -VHDX

Back to jump list.

Change vDisk mode:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” set disk -p diskLocatorName=YourDiskName siteName=YourSiteName storeName=YourStoreName -r writeCacheType=9 writeCacheSize=SizeInMB

PowerShell

Set-PvsDisk -Name ““YourDiskName” -StoreName “YourStoreName” -SiteName “YourSiteName” -WriteCacheType “9” -WriteCacheSize “SizeInMB”

WriteCacheType: 0 (Private), (other values are standard image) 1 (Cache on Server), 3 (Cache in Device RAM), 4 (Cache on Device Hard Disk), 6 (Device RAM Disk), 7 (Cache on Server, Persistent), or 9 (Cache in Device RAM with Overflow on Hard Disk). Min=0, Max=9, Default=0

Back to jump list.

Add vDisk information:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” SET DISK -p disklocatorName=YourDiskName sitename=YourSiteName storename=YourStoreName -r longDescription=Description date=DATE author=Author title=Title company=Company internalName=InternalName originalFile=OriganalFile

PowerShell

Set-PvsDisk -Name ““YourDiskName” -StoreName “YourStoreName” -SiteName “YourSiteName” -longDescription “Description” -date “DATE” -author “Author” -title “Title” -company “Company” -internalName “InternalName” -originalFile “OriganalFile”

Back to jump list.

Create a new vDisk version:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” RunWithReturn CreateMaintenanceVersion -p diskLocatorName=YourDiskName siteName=YourSiteName StoreName=YourStoreName

PowerShell

New-PvsDiskMaintenanceVersion -DiskLocatorName ““YourDiskName” -StoreName “YourStoreName” -SiteName “YourSiteName”

Back to jump list.

Promote vDisk version:

To production version

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” Run PromoteDiskVersion -p diskLocatorName=YourDiskName siteName=YourSiteName StoreName=YourStoreName

PowerShell

Invoke-PvsPromoteDiskVersion -DiskLocatorName ““YourDiskName” -StoreName “YourStoreName” -SiteName “YourSiteName”

To test version

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” Run PromoteDiskVersion -p diskLocatorName=YourDiskName siteName=YourSiteName StoreName=YourStoreName test=1

PowerShell

Invoke-PvsPromoteDiskVersion -DiskLocatorName ““YourDiskName” -StoreName “YourStoreName” -SiteName “YourSiteName” -Test

Back to jump list.

Revert vDisk version:

To test

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” Run RevertDiskVersion -p diskLocatorName=YourDiskName siteName=YourSiteName StoreName=YourStoreName test=1

PowerShell

Invoke-PvsRevertDiskVersion -DiskLocatorName ““YourDiskName” -StoreName “YourStoreName” -SiteName “YourSiteName” -test

To maintenance

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” Run RevertDiskVersion -p diskLocatorName=YourDiskName siteName=YourSiteName StoreName=YourStoreName

PowerShell

Invoke-PvsRevertDiskVersion -DiskLocatorName ““YourDiskName” -StoreName “YourStoreName” -SiteName “YourSiteName”

Back to jump list.

Merge vDisk version:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” Run MergeDisk -p diskLocatorName=YourDiskName siteName=YourSiteName StoreName=YourStoreName

PowerShell

Merge-PvsDisk -DiskLocatorName ““YourDiskName” -StoreName “YourStoreName” -SiteName “YourSiteName”

Back to jump list.

Merge vDisk versions to new base:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” Run MergeDisk -p diskLocatorName=YourDiskName siteName=YourSiteName StoreName=YourStoreName base=1

PowerShell

Merge-PvsDisk -DiskLocatorName ““YourDiskName” -StoreName “YourStoreName” -SiteName “YourSiteName” -NewBase

Back to jump list.

Change vDisk licensing type:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” SET DISK -p disklocatorName=YourDiskName sitename=YourSiteName storename=YourStoreName -r licenseMode=2

PowerShell

Set-PvsDisk -DiskLocatorName ““YourDiskName” -StoreName “YourStoreName” -SiteName “YourSiteName” -LicenseMode “2”

1 is MAK 2 is KMS

Back to jump list.

Create a new device collection:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” Add Collection -r collectionName=NewCollectionName siteName=YourSiteName

PowerShell

New-PvsCollection -SiteName “YourSiteName” – CollectionName “NewCollectionName”

Back to jump list.

Create a new device:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” Add Device -r collectionName=NewCollectionName siteName=YourSiteName deviceName=NewDevice deviceMAC=00-00-00-00-00-00

PowerShell

New-PvsDevice -SiteName “YourSiteName”  -CollectionName “NewCollectionName” -DeviceName “NewDevice” -DeviceMac “00-00-00-00-00-00”

Back to jump list.

Assign vDisk to a collection:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” run assigndisklocator -p collectionName=NewCollectionName removeexisting=1 disklocatorname=YourDiskName sitename=YourSiteName storename=YourStoreName

PowerShell

Add-PvsDiskLocatorToDevice -SiteName “YourSiteName” -StoreName “YourStoreName” -DiskLocatorName ““YourDiskName” -CollectionName “NewCollectionName” -RemoveExisting

Back to jump list.

Assign vDisk to a device:

MCLI.exe Command Line

“C:\Program Files\Citrix\Provisioning Services Console\MCLI.exe” run assigndisklocator -p deviceName=DeviceName removeexisting=1 disklocatorname=YourDiskName  sitename=YourSiteName storename=YourStoreName

PowerShell

Add-PvsDiskLocatorToDevice -SiteName “YourSiteName” -StoreName “YourStoreName” -DiskLocatorName ““YourDiskName” -DeviceName “DeviceName” -RemoveExisting

Back to jump list.


The best way to image your target device to a vDisk is of course to use the Base Image Script Framework (BIS-F). This script will seal and image your device. Check it out here.


I hope this was informative. For questions or comments you can always give a reaction in the comment section or contact me: