Creating a virtual smart card in a Hyper-V guest system

For test environments, it is often helpful to be able to work with smart cards. Below is a brief guide on how to set up a virtual smart card in a Hyper-V guest using a virtualized Trusted Platform Module (TPM).

Implementation

Do you know TameMyCerts? TameMyCerts is an add-on for the Microsoft certification authority (Active Directory Certificate Services). It extends the function of the certification authority and enables the application of rule sets to realize the secure automation of certificate issuance. TameMyCerts is unique in the Microsoft ecosystem, has already proven itself in countless companies around the world and is available under a free license. It can be downloaded via GitHub and used free of charge. Professional maintenance is also offered.

The prerequisite is that a Trusted Platform Module has been installed and commissioned on the host system.

The virtual machine must be Generation 2.

New virtual machine wizard (German UI), step "Generation angeben": "Generation 2" selected

In the virtual machine settings, you can then activate the Trusted Platform Module under Security.

Hyper-V settings for CLIENT9 (German UI), "Sicherheit": "Trusted Platform Module aktivieren" highlighted in yellow

To use the virtual smart card in the Hyper-V guest, the "Enhanced Session" must be disabled, otherwise there will be a connection via Remote Desktop, which will pass the smart card readers from the host system to the guest.

Virtual machine connection (German UI), menu "Ansicht": entry "Erweiterte Sitzung" highlighted

The virtual smart card can then be created with the following command (as admin).

tpmvscmgr.exe create ^
    /name TestVSC ^
    /pin prompt ^
    /adminkey random ^
    /generate

During the creation of the virtual smart card, you will be asked for a PIN, which must be at least eight characters long by default.

Command prompt: tpmvscmgr.exe create with /name TestVSC, /pin prompt, /adminkey random and /generate reports "TPM Smart Card created."

External sources