Purpose
When running a deployment, the deployment fails with the following error.
Command couldn't be run: WTSQueryUserToken: Os { code: 1008, kind: Uncategorized, message: "An attempt was made to reference a token that does not exist." }
Cause
This error occurs when the following conditions are both met:
- A custom package has been configured with the Run as mode set to "Logged on user."
- The user working on the target device is connected via a Remote Desktop (RDP) session.
Resolution
Ensure that the user working on the target device logs directly into the machine to create a local logon session. Currently, PDQ Connect does not support running deployments in the context of a remote desktop session. This error can be prevented if the user logs out of the RDP session and then physically logs back in while present at the computer. Alternatively, the "Run Mode" can be set to "Local System," which ensures that the logged on user is not considered during the deployment."
Note about Hyper-V
The "Enhanced Session Mode" setting in Hyper-V will cause connections made directly through Hyper-V Manager to use RDP for the connection method. This setting is enabled by default in Windows 10/11 and may optionally be enabled on Windows Server editions. To avoid this error when working on Hyper-V virtual machines, make sure that that the session type is set to "Basic Session" when connecting through Hyper-V Manager. This can be toggled using the session button on the top toolbar.