Posted in : Citrix, Virtual Apps and Desktops, Windows Server By Robert Skyllberg Translate with Google ⟶

5 years ago

In a recent use-case that I stumbled across, I wanted to monitor a few different things in a Citrix-environment with Provisioning Services technology.
In this specific blog-post I’ll show you how I configured monitoring of vDisk Replication with Provisioning Services (PVS) Powershell SnapIn.

Provisioning Services Powershell SnapIn

In case you don’t have Provisioning Services Powershell SnapIn configured already, you can read more about this here. This particular script is written with the Management Command Line Interface (MCLI).
When working with MCLI-SnapIn your regexp (Regular expression) knowledge will come in handy. I’ve only commented what my specific regexp replaces does in each section, I recommend taking help from the following sites in case you’re in need of assistance:


For this case, we have different Device Collections in which I wanted to separately monitor using NRPE (Nagios Remote Plugin Execution). First off start with establishing a connection to your PVS server and predefining prerequisite parameters.

    $exitCode = 0
    #Variables for MCLI connection setup
    $ServerName = hostname
    $ServerPort = "54321"
    #Connect to your Provisioning Service installation
    Add-PSSnapIn mclipssnapin
    Mcli-Run setupconnection -p server=$ServerName,port=$ServerPort >$null 2>&1

The only information you actually need is the $vDisk variable, for reuse of the script on several sites you can use the $StorePath variable. In this scenario we have more than one store, which makes us unable to retrieve the store path without the predefined $StoreName parameter. In deployments with one store you could use this row instead of the one in below section:
$StorePath = (Mcli-get Store -f Path 2>$null | Select-String ”path:”) -replace ”path:\s”
Normally you’d exit the else statement with a UNKNOWN exit code (3), but I prefer exiting this scripts else statement with critical due to the importance of the monitoring. Below is the execution of what’s checked:

    #Fetching path for vDisk storage and applied vDisk for Collection
    $StorePath =( (Mcli-Get store  -p storename=$storename -f Path 2>$null) | Select-string "path:") -replace "path:\s"
    $vDisk= ( (Mcli-Get DeviceInfo -p sitename=$SiteName,collectionname=$CollectionName -f diskLocatorName 2>$null) | Select-string "diskLocatorName" | Select-Object -First 1) -replace ".*:\s$StoreName\W"
    $QueryVDiskPVP = Test-Path -Path "$StorePath\$vDisk.pvp"
    $QueryVDiskVHDX = Test-Path -Path "$StorePath\$vDisk.vhdx"
        if ($QueryVDiskPVP -eq $False -or $QueryVDiskVHDX -eq $false){
            $exitCode = 2
            $Output = "Critical - All active vDisk files for collection $CollectionName NOT found on server $ServerName"
        elseif($QueryVDiskPVP -eq $True -and $QueryVDiskVHDX -eq $True){
            $exitCode = 0
            $Output = "OK - All active vDisk files for collection $CollectionName found on server $ServerName"
            $exitCode = 2
            $Output = "Critical - Check failed, unexpected value(s) returned"
    Write-Output $Output
    exit $exitCode

-replace ”path:\s” cleans my output
FROM Path: D:\vDiskPath\vDisks
TO D:\vDiskPath\vDisks
-replace ”.*$StoreName\W” cleans my outout
FROM diskLocatorName: Store Name\vDiskName
TO vDiskName
If you have any questions, feel free to email me at or leave a comment below.

Tags : Citrix; XenApp; XenDesktop, PowerShell, Provisioning Services

Personlig rådgivning

Vi erbjuder personlig rådgivning med författaren för 1400 SEK per timme. Anmäl ditt intresse i här så återkommer vi så snart vi kan.

Add comment

Your comment will be revised by the site if needed.