[Updated] Citrix PVS: Sync Local vDisk Store #PowerShell
I’ve reworked the Sync-PvsLocalStore.ps1 script. And from compatibility perspective it supports now vDisks in avhdx as well as avhd format.
Sync-PvsLocalStore.ps1 supports Citrix Provisioning Services Farms w/ local vDisk store. This kind of architecture is not best practice but in the field, especially among the mid-sized companies you’ll find such PVS farms.
The purpose of this script is to copy or rather sync changed and new versions of one or more given vDisks between the local Stores within a Farm of two or more PVS servers. Basically, you can think of the Sync-PvsLocalStore.ps1 as a wrapper for Robocopy.exe /MIR with some extra brains on top. That is because it is able to detect and exclude a Maintenance Version of a vDisk from the copy process, meaning that the script only spreads out the latest Production and Test versions of a vDisk while it doesn’t bloat the stores with Maintenance versions that is work in progress typically.
The usage is very simple. Look at this example:
PS C:\Script> .\Sync-PvsLocalStore.ps1 -MasterServer $env:COMPUTERNAME -MemberServer PVS02,PVS03 -StorePath D:\XenWorkload -DiskName WS2008R2-XA65Worker,WS2012R2-XA76Worker -SiteName DUS -StoreName XenWorkload
You need to specify one ‘MasterServer’, one or more ‘MemberServer’, the path of the Store (needs to be the same on each server), one or more vDisk names, the name of the corresponding Site and Store. The two latter params help the script to identify any Maintenance Version.
Sync-PvsLocalStore.ps1 needs to be run on a system where the PVS Console or rather its command-line interface MCLI.EXE is installed. (Although there’s a PowerShell module for PVS, the script utilizes the old school MCLI.EXE in order to support a wider range of PVS versions.)
Please note: The script leverages robocopy’s MIR switch; meaning that it may delete so called EXTRA files on the given member PVS server(s) that are not present in the local vDisk store of the given master PVS server! Therefore, this script makes only sense when you consequently use only one PVS Server for vDisk maintenance. You need to keep that in mind when using this script.
Hope this helps