In case you ever need to determine whether a Provisioning Server target device is running in standard or private mode please continue reading.
The issue
In specific cases, the need may arise to be able to distinguish a PVS target device running in Standard or Private mode.
Perhaps you would like to configure one registry value differently or perhaps you require a different environment variable depending on the mode the target device is running in.
Such configurations are easily handled by using a Group Policy Preference item and an appropriate Item-Level Targeting item. But the question is, how can you determine which mode your target device is running in?
The solution
One way to check the mode of a target device is by reading the file C:\Personality.ini.
First of all, this file is only present on a PVS target device and secondly, the mode is written in readable text within the file. With the help of a script, the mode can be easily retrieved.
When you open the file in an editor you will see six lines. One of the lines starts with _DiskMode. The value after the equal sign is the one we are after:
- _DiskMode=S -> standard mode
- _DiskMode=P -> private mode
Geek note: for all of you old-school Citrix technicians out there, check out line four [ArdenceData]. Ardence is the company which developed the original Provisioning Server software (before it was called that) and was acquired by Citrix in 2006.
Anyway, back to our problem at hand. The next step is to create a small PowerShell script that can be added as a startup script to one of your existing group policies.
The PowerShell script reads the Personality.ini file and then writes the current mode to the registry. The value name is PVSTargetDeviceMode and is stored in the both the 32 and 64-bit registry path:
- HKLM\SOFTWARE\MyKey
- HKLM\SOFTWARE\Wow6432Node\MyKey
The value is either Standard or Private.
Note: please change the registry key to a path of your choice (and the value name for that matter).
The script looks something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
######################################################################################################################### # Write the PVS mode ('standard' or 'private') of the current machine to the registry (for PVS workers only) # Note: this registry value can be used for example for Item-Level Targeting in a Group Policy Preference ######################################################################################################################### $File = "$env:SystemDrive\Personality.ini" Write-Host "Write the PVS mode ('standard' or 'private') of the current machine to the registry (for PVS workers only)" if ( Test-Path $File ) { if ( Select-String -Path $File -pattern "`_DiskMode`=S") { Write-Host "The current machine is a PVS target device running in STANDARD mode" # Write the 64-bit registry value (and create the registry key if it does not exist) $RegKey = 'HKLM:\SOFTWARE\MyKey' if (!(Test-Path $RegKey)) { New-Item -Path $RegKey -Force | Out-Null } try { New-ItemProperty -Path $RegKey -Name 'PVSTargetDeviceMode' -Value 'Standard' -PropertyType 'String' -Force | Out-Null Write-Host "OK - the value 'PVSTargetDeviceMode' was written to the registry (64-bit)" } Catch { Write-Host "ERROR - writing to the registry failed" } # Write the 32-bit registry value (and create the registry key if it does not exist) $RegKey = 'HKLM:\SOFTWARE\Wow6432Node\MyKey' if (!(Test-Path $RegKey)) { New-Item -Path $RegKey -Force | Out-Null } try { New-ItemProperty -Path $RegKey -Name 'PVSTargetDeviceMode' -Value 'Standard' -PropertyType 'String' -Force | Out-Null Write-Host "OK - the value 'PVSTargetDeviceMode' was written to the registry (32-bit)" } Catch { Write-Host "ERROR - writing to the registry failed" } } else { Write-Host "The current machine is a PVS target device running in PRIVATE mode" # Write the 64-bit registry value (and create the registry key if it does not exist) $RegKey = 'HKLM:\SOFTWARE\MyKey' if (!(Test-Path $RegKey)) { New-Item -Path $RegKey -Force | Out-Null } try { New-ItemProperty -Path $RegKey -Name 'PVSTargetDeviceMode' -Value 'Private' -PropertyType 'String' -Force | Out-Null Write-Host "OK - the value 'PVSTargetDeviceMode' was written to the registry (64-bit)" } Catch { Write-Host "ERROR - writing to the registry failed" } # Write the 32-bit registry value (and create the registry key if it does not exist) $RegKey = 'HKLM:\SOFTWARE\Wow6432Node\MyKey' if (!(Test-Path $RegKey)) { New-Item -Path $RegKey -Force | Out-Null } try { New-ItemProperty -Path $RegKey -Name 'PVSTargetDeviceMode' -Value 'Private' -PropertyType 'String' -Force | Out-Null Write-Host "OK - the value 'PVSTargetDeviceMode' was written to the registry (32-bit)" } Catch { Write-Host "ERROR - writing to the registry failed" } } } else { Write-Host "The current machine is not a PVS target device" } |
Note: the script only contains basic error handling and logging (and no functions). Please customize the script to meet your requirements.
You can execute this script anyway you like, but I recommend that you add the contents to an existing startup script. You can also use the above script as a startup script directly.
The startup script can also run on machines without the Personality.ini file. The script first checks if the file is available. If not, than an message is displayed stating that the current machine is not a PVS target device.
The result
The registry value PVSTargetDeviceMode can now be used as an Item-Level Targeting item in one of your Group Policy Preferences (New Item \ Registry Match). The match type should be set to Match value data. Use the screenshot below as an example.
Dennis Span works as a Lead Account Technology Strategist at Cloud Software Group in Vienna, Austria. He holds multiple Citrix certifications (CCE-V). Dennis has been a Citrix Technology Advocate (CTA) since 2017 (+ one year as Citrix Technology Professional, CTP). Besides his interest in virtualization technologies and blogging, he loves spending time with his family as well as snowboarding, playing basketball and rowing. He is fluent in Dutch, English, German and Slovak and speaks some Spanish.