How to distinguish a PVS target device running in Standard or Private mode

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

PVS target device mode registry value

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:

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.

Group Policy Management Console startup/shutdown scripts

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.

Group Policy Preference Item-Level Targeting example

Leave a Reply

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

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