PVS Info to Environment Variables / Event Log Refreshed
In my old post I presented a Powershell startup script to grab some info from the PVS image and pump it into the eventlogs and environment variables for consumption. I refreshed this for the VHDX disks and "Cache in Ram with overflow" cache type.
Start by creating the event log from an elevated poweshell session by issuing the command:
New-EventLog -LogName Application -Source "Xenapp_Custom"
I run the script below in the local startup scripts on the PVS images.
------------PVS_Personality.ps1------------------------
$disk="ID not found"
$file="c:\personality.ini"
IF(Test-Path $File){
$data=get-content $file
Foreach ($line in $data) {
if ($line.Contains("DiskName")){$iname=$line.replace("$","").replace("DiskName=","").replace(".vhdx","").replace(".vhd","")}
if ($line.Contains("WriteCacheType")){$wc=$line.replace("$","").replace("WriteCacheType=","")}
}
switch ($wc)
{
"0" {$wc1="PV"}
"4" {$wc1="CD"}
"6" {$wc1="CR"}
"9" {$wc1="CRO"}
"1" {$wc1="Server";Write-EventLog -LogName Application -Source "XenApp_Custom" -EntryType Error -EventID 911 -Message "PVS ALERT. VDisk is set to Cache on server. Immediate action is required to prevent an outage if this is a PROD image. Image: $iname"}
default {$wc1="OTHER";Write-EventLog -LogName Application -Source "XenApp_Custom" -EntryType Warning -EventID 911 -Message "PVS ALERT. Nonstandard VDisk configuration has been detected. Image: $iname"}
}
$disk=$iname+"_"+$wc1
}
ELSE
{$disk=$env:computername + "_Local"}
[Environment]::SetEnvironmentVariable("PVS_Disk",$disk,"Machine")
---------------END OF LINE------------