Citrix PVS: Measure RAM Cache Usage

When you want to get a quick overview of the RAM write cache usage of your target devices you can use the following PowerShell script.

1. If not done already, allow running unsigned scripts:

Set-ExecutionPolicy RemoteSigned

2. Install the MCLI PowerShell snapin:

$installutil = $env:systemroot + ‘Microsoft.NETFramework64v2.0.50727installutil.exe’
&$installutil McliPSSnapIn.dll

3. Add the MCLI snapin to your PowerShell environment:

 Add-PSSnapin -Name McliPSSnapIn

4. Run the following PowerShell script on your PVS server:

function get-value{
return $strText.SubString($strText.IndexOf($strDelimiter)+2)
function get-name{
return $strText.SubString(0,$strText.IndexOf($strDelimiter))
Add-PSSnapin McliPS* -ErrorAction SilentlyContinue
$all = @()
$obj = New-Object System.Collections.ArrayList
$lines = Mcli-Get DeviceInfo -f ServerName,`
for($i=0;$i -lt $lines.length;$i++){
if(($lines[$i].length -gt 0) -and ($lines[$i].contains(“:”)) -and -not ($lines[$i] -match “Executing: Get “)){
$name = get-name -strText $lines[$i] -strDelimiter “:”
$value = get-value -strText $lines[$i] -strDelimiter “:”
if ($name -eq “status” -and $value.Length -le 0){
$value = “0”
if ($value.Contains(“,”) -and $name -eq “status”){
$obj | Add-Member -membertype noteproperty -name $name -Value $value.Split(“,”)[1]
$obj | Add-Member -membertype noteproperty -name $name -Value $value
if($lines[$i].contains(“#”) -or (($i+1) -eq $lines.length)){
$all += $obj
$obj = New-Object psObject

$all | Where-Object -FilterScript { ([int] $_.status -gt “0”) -and ([int]$_.status -le “100”) } | Sort-Object {[int] $_.status} -descending | Format-Table @{Expression={$_.deviceName};Label=”Device”}, @{Expression={$_.status};Label=”RAM Cache Used (%)”} -autosize

Thanks to ctxfarmer for providing the base of the script.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.