PVS Writecache Usage Script

When using PVS cache to Ram fallback to disk, the initial values provided by the PVS setup wizard are pretty conservative. To better improve performance for your environment you can increase the size of the Ram, but how do you know if you are using the best amount?

There isn’t a built-in tool to see the Ram usage, but you can at least see the size of the Disk usage by looking at the D:\vdiskdif.vhdx. If the size of that vhdx file is only 4,096 KB, your Ram cache is too large. But by how much?

To get the usage of the Ram cache, you will first need to get poolmon.exe from the Windows Driver Kit. The link to which you can locate here. https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/poolmon

Once you have extracted poolmon.exe from the kit, save it to a network location that your PVS targets will have read access to. Then download the following PowerShell script into that same network location. You should only need to modify the $poolmonnetwork variable and you are ready to go. Feel free to modify this script as needed, such as reading from a list of machines, or saving the data out to something that isn’t the console.

$cred = Get-Credential
$server = Read-Host "Please enter the hostname of the Citrix Server you wish to scan."
[string]$logfile = 'd:\poolmon.txt'
$poolmonnetwork = "<yourshare>\poolmon.exe"
$poolmonlocal = "c:\temp\poolmon.exe"
copy-item $poolmonnetwork -Destination "\\$server\c$\temp\poolmon.exe"
Write-Host $server
Invoke-Command -Computername $server -Credential $cred -ScriptBlock {Remove-Item $using:logfile -Force -EA SilentlyContinue }
Invoke-Command -Computername $server -Credential $cred -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c $using:poolmonlocal -n $using:logfile"}
Write-Host "Ram Cache Used"
Invoke-Command -Computername $server -Credential $cred -ScriptBlock {((Get-Content $using:logfile | ? {$_ -like "*VhdR*"}) -split "\s+")[6] /1gb}
Write-Host "Disk Cache Used"
Invoke-Command -Computername $server -Credential $cred -ScriptBlock {(Get-ChildItem "d:\vdiskdif.vhdx" -Force).Length /1mb}
Invoke-Command -Computername $server -Credential $cred -ScriptBlock {Remove-Item $using:poolmonlocal -Force -EA SilentlyContinue }
Invoke-Command -Computername $server -Credential $cred -ScriptBlock {Remove-Item $using:logfile -Force -EA SilentlyContinue }

To use the script just open up an Admin Powershell session and execute the script with & “<\\server\share\>WriteCacheCheck.ps1”

You will be prompted to enter admin credentials, then it will ask you the name of the PVS machine you wish to check. After that it will copy all the files as needed, generate the reported information, and then cleanup after itself leaving nothing on the target system.

As with all my scripts, let me know what you think, and how you feel it can be improved.

Leave a comment

Your email address will not be published. Required fields are marked *