Links

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 gcr.io/instruqt/guacamole container to your sandbox configuration:
config.yml
version: "3"
containers:
- name: guac
image: gcr.io/instruqt/guacamole
shell: /bin/bash
ports:
- 8080
virtualmachines:
- 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.
setup-guac
#!/bin/bash
cat <<'EOF' > /config/guacamole/user-mapping.xml
<user-mapping>
<authorize
username="guac_user"
password="guac_password">
<connection name="srv01">
<protocol>rdp</protocol>
<!-- 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>
</connection>
</authorize>
</user-mapping>
EOF
  1. 1.
    Add a service tab for Guacamole. This will add a Remote Desktop tab that automatically connects to the Windows VM.
assignment.md
tabs:
- 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