Windows VMs

Run instances of Windows in sandboxes.

Running 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.

Add 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.

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.

Step 1: Add Guacamole

Add the gcr.io/instruqt/guacamole container to your sandbox.

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

Step 2: Configure Guacamole

Inject Guacamole configuration using a setup script. To allow Guacamole to connect to a Windows VM, you can write the connection configuration to the/config/guacamole/user-mapping.xml file. Make sure to update the username and password parameters, so they are valid for the 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

Step 3: Display Guacamole connection

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

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

The following check script checks if the C:\Users\instruqt\Desktop\check.txt file is present:

$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

The following solve script creates the C:\Users\instruqt\Desktop\check.txt file.

$ErrorActionPreference = "Stop"

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

Last updated