Windows 11 Golden Image Preparation for OCI | Sysprep Guide

Golden Image Preparation: Windows 11 Sysprep Automation for OCI

Overview

This guide walks you through the automated process for preparing a Windows 11 virtual machine as a golden image for deployment on Oracle Cloud Infrastructure (OCI). The process uses two PowerShell scripts that run before and after a reboot to validate the environment, install required software, and execute Sysprep to generalize the image.

The automation consists of three files:

  • _Config.ps1 — shared configuration values
  • Step1_PreReboot.ps1 — environment validation and cleanup (runs before reboot)
  • Step2_PostReboot.ps1 — software installation and Sysprep (runs after reboot)

Prerequisites

  • A Windows 11 virtual machine running on OCI
  • Administrator privileges on the VM
  • Minimum 2 GB of free disk space
  • Internet connectivity (required for downloading software)
  • The Network ID and Gateway URLs for your Thinfinity Workspace environment

Step 1: Pre-Reboot — Validation and Cleanup

The first script validates the environment and prepares the VM for imaging. It performs the following checks and actions automatically:

CheckAction
Administrator privilegesVerifies the script is running as Administrator
Windows 11Confirms the OS version is Windows 11
Disk spaceEnsures at least 2 GB of free disk space
Internet connectivityTests network access for software downloads
SysprepVerifies the Sysprep executable is available
BitLockerDisables encryption and waits for full decryption
Network (IP/DNS)Switches static configuration to DHCP if needed
Remote DesktopEnables RDP and its firewall rule if disabled
Remote Desktop UsersDisplays group members for review
Pre-existing softwareRemoves Cloudbase-Init and/or VirtualBox Guest Additions if present

The VM reboots after this step completes.

Step 2: Post-Reboot — Installation and Sysprep

After the reboot, the second script installs the required software and runs Sysprep to generalize the image:

PhaseAction
Download softwareDownloads the Thinfinity Workspace Agent and Cloudbase-Init installers
Generate unattend.xmlConfigures OOBE skip, Administrator password, and RDP settings
Kill processesTerminates and disables non-essential services, tasks, and startup entries
Thinfinity AgentSilent install and configuration with your Network ID and Gateway URLs. Pauses for manual log verification.
Cloudbase-InitSilent install (service user: cb, metadata password disabled)
AppX cleanupRemoves conflicting AppX packages that block Sysprep
Remove TeamsUninstalls Microsoft Teams
SysprepExecutes sysprep /generalize /oobe /shutdown

The VM shuts down automatically after Sysprep completes.

How to Run the Scripts

Prepare the Files

Copy the three script files (_Config.ps1, Step1_PreReboot.ps1, Step2_PostReboot.ps1) to the Downloads folder of the logged-in user on the target VM.

Set the Execution Policy

Open PowerShell as Administrator. If script execution is restricted, run the following command to allow scripts for the current session only:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

This allows scripts to run only for the current session without changing the system-wide policy.

Execute the Process

  1. Navigate to the Downloads folder:
    cd ~\Downloads
  2. Run Step 1 (no parameters required):
    .\Step1_PreReboot.ps1
    The script validates the environment, applies fixes, and prompts you to reboot.
  3. Reboot the VM. After the reboot, open PowerShell as Administrator again and navigate back to the Downloads folder.
  4. Run Step 2 with the required parameters — your -NetworkID and -Gateways:
    .\Step2_PostReboot.ps1 -NetworkID "your-network-id" -Gateways "https://gateway1.example.com,https://gateway2.example.com"
    The script will pause after configuring the Thinfinity Agent for manual log verification.Press ENTER only after confirming connectivity in the agent logs.
  5. After Sysprep completes, the VM shuts down automatically. Proceed to create the custom image.

Creating the Custom Image

Important: Wait 20 to 30 minutes after the VM shuts down before creating the custom image. Do not start or modify the VM state before creating the image.

Once the wait period has passed, create the custom image from the OCI Console using the stopped VM as the source.

User Accounts on Deployed VMs

VMs created from the golden image contain two user accounts:

UserSourcePurposePost-Deploy Status
AdministratorEnabled by unattend.xmlInitial configurationDisabled after first boot
Terraform userCreated by Cloudbase-InitVM access (RDP)Active

The built-in Administrator account is temporarily enabled during deployment for initial configuration. It is automatically disabled after the first boot, leaving only the Terraform-provisioned user as the active account.

Troubleshooting

Step 1 fails a validation check

Review the script output to identify which check failed. Common issues include insufficient disk space, no internet connectivity, or an unsupported OS version. Resolve the underlying issue and re-run Step 1.

Thinfinity Agent does not show connectivity in the logs

Verify that the -NetworkID and -Gateways values are correct and that the VM has outbound network access to the gateway URLs. Do not press ENTER until the logs confirm a successful connection.

Sysprep fails due to AppX packages

The script automatically removes known conflicting AppX packages (including Microsoft Teams). If Sysprep still fails, check the log at C:\Windows\System32\Sysprep\Panther\setupact.log to identify any remaining problematic packages, remove them manually, and re-run Step 2.

Blog:


    • Related Articles

    • How to Enable VDI Manager

      Introduction to VDI Manager in Thinfinity Workspace The Virtual Desktop Infrastructure (VDI) Manager is an integral component of the Thinfinity Workspace, designed to streamline and simplify the management of cloud-based virtual resources. This ...
    • What's New on Thinfinity Remote Workspace 8

      Introduction Welcome to our comprehensive guide to the Thinfinity® Workspace 8. This article will introduce you to the product's groundbreaking features, new connection protocols, and enhanced user experience. Thinfinity Workspace 8 is the epitome of ...
    • Theme customization API in Thinfinity® Workspace

      Product: Thinfinity Workspace Version: 7 and later Introduction The theme customization API in Thinfinity Workspace allows users to personalize the visual style of the entire interface. Out of the box, any user will be able to choose the color layout ...
    • Azure Credentials: Registering Azure Credentials in Thinfinity VDI Manager for Cloud Control

      Intro In today's cloud-centric IT landscape, integrating Azure cloud services with Thinfinity's VDI Manager is a strategic move to enhance control and management of virtual desktop infrastructures. This tutorial, titled "Azure Credentials," is ...
    • Configure SAML-based SSO in Oracle Cloud for Thinfinity® Workspace

      In this tutorial, we will guide you through the process of configuring SAML-based Single Sign-On in Oracle Cloud for Thinfinity Workspace. Provide your team with a secure and streamlined access experience, ultimately enhancing your team's ...