Run a Windows VM

This guide describes how to run a Windows Virtual Machine (VM).

How to run Windows-based VM images?

Windows VMs support all the same features as our Linux-based sandbox hosts, including running Lifecycle scripts, PowerShell-based Terminal tabs, and the built-in file editor.
In addition, the Instruqt platform injects an instruqt user with password Passw0rd! and a pre-configured ssh-key to facilitate interaction with other hosts in the environment. This user has Administrator rights.
As all the VMs run on the Google Cloud Platform, you can use any Windows version supported by GCP. For Windows Server instances, GCP can provide on-demand licenses. For Windows Client (For example, Windows 7 and 10), you must bring your license.
Read more about running Windows workloads on GCP.

Adding a Remote Desktop tab

If you want to give your users access to a virtual desktop, you can use a browser-based Remote Desktop client (like Apache Guacamole) to give users access.
Native Remote Desktop tab support is on our roadmap. Contact us for more information.
The following is a Guacamole based example to get you started quickly. Instruqt created a Docker container image with a fully functioning Guacamole installation, which you can add to your track's sandbox:
  1. 1.
    Add the container to your sandbox configuration:
version: "3"
- name: guac
shell: /bin/bash
- 8080
- name: windows
image: instruqt/windows-server
machine_type: n1-standard-2
  1. 1.
    Inject Guacamole configuration using a setup script. To allow Guacamole to connect to a Windows VM, you can write the connection configuration to /config/guacamole/user-mapping.xml. Make sure to update the username and password parameters, so they are valid for the Windows VM.
cat <<'EOF' > /config/guacamole/user-mapping.xml
<connection name="srv01">
<!-- hostname as defined in instruqt config.yml -->
<param name="hostname">windows</param>
<param name="port">3389</param>
<!-- domain/username/password must be valid for the target host -->
<param name="domain"></param>
<param name="username">instruqt</param>
<param name="password">Passw0rd!</param>
<param name="ignore-cert">true</param>
  1. 1.
    Add a service tab for Guacamole. This will add a Remote Desktop tab that automatically connects to the Windows VM.
- title: Remote Desktop
type: service
hostname: guac
path: /#/client/c/srv01?username=guac_user&password=guac_password
port: 8080
You can also play an example track for this setup. And check out the source code for this example track.

Windows Lifecycle Scripts

Windows VMs support Powershell lifecycle scripts with the same naming convention as Linux hosts. For example: check-windows would run a check on the host named windows. Check and solve script examples are below. Use a Write-Output and exit 1 to trigger the failure message to your user.

Powershell check script

$ErrorActionPreference = "Stop"
if ( !(Test-Path -Path "C:\Users\instruqt\Desktop\check.txt" )) {
Write-Output "FAIL: Please create a check.txt file on the Desktop"
exit 1
Write-Output "C:\Users\instruqt\Desktop\check.txt exists"

Powershell solve script

$ErrorActionPreference = "Stop"
New-Item -Path "C:\Users\instruqt\Desktop\check.txt" -ItemType "file" -Force