Windows adaptations


For Windows systems, Google Cloud Migrate for Compute Engine (formerly Velostrata) provides some OS adaptation scripts by default. You can also provide additional scripts by saving them to this directory:

c:\Program Files\Velostrata\UserScripts

The registry is updated to run the scripts (also known as UserTasks) on startup depending on the environment where the VM is running (also known as the MachineState).

The three options for MachineState are:

  • Origin - The scripts run when the VM is in the on-premises environment
  • Velostrata - The scripts run when the VM is running in cached mode.
  • Detach - The scripts run after the detach operation.

The tasks are executed sequentially in alphabetical order. If the order of the tasks is important, use numerical prefixes in the task names, such as 10_ResetWMI and 20_ConfigKMS. Be sure to use absolute paths in the user script because relative paths won't resolve correctly.

PowerShell Assistance Script

Migrate for Compute Engine provides a PowerShell module that simplifies installation of your user script on a relevant VM. The script validates user input to prevent inconsistent states, copies the user script to the UserScripts directory, and creates a tree if needed. The PowerShell module also creates the relevant registry keys and their trees, and fills in the appropriate values.

Module name: MigrateForGCEUserScripts.psm1

Available commands are: Install-VelosUserScript and Remove-VelosUserScript

To use the assistance script:

  1. Install the module.
  2. Download the PowerShell User Scripts from the Downloads page.
  3. Import the module (use the correct path for your deployment):

    Import-Module .\MigrateForGCEUserScripts.psm1 -force

  4. Run the assistance script for each OS adaptation script/task you want to configure. For example:

    Install-VelosUserScript -FilePath .\resetWMI.ps1 -TaskName "10_ResetWMI" -MachineState Detach -TaskType RunAlways -Platform GCP 

    • FilePath is the script filename and path, and can be either a relative or an absolute path.

    • TaskName is a unique name you want to use for the task. See the note about sequencing above.

    • MachineState is one of the following three options:

      • Origin - on-premises environment.
      • Migrate for Compute Engine - The scripts will run when the VM is running in cache mode.
      • Detach - The scripts will run after the detach operation.
    • TaskType is one one of the following options:

      • RunOnce - This means the task will run once on the next boot and is then deleted.
      • RunAlways - The task runs on every boot.
    • Platform is one of the following environments in which the VM is running:

      • Aws
      • All
  5. The script removal command validates that a task exists and then deletes it from the registry, and optionally from the scripts directory.

    Remove-VelosUserScript -TaskName "ResetWMI" -MachineState Detach -DeleteScriptFile


    • TaskName is similar to the one provided during scriptInstall.
    • DeleteScriptFile is an optional parameter. Examples:
      Install-VelosUserScript -FilePath .\KMS\Config-Kms_AWS.ps1 -TaskName "10_configKMS" -MachineState Velostrata -TaskType RunAlways
      Remove-VelosUserScript -TaskName "10_configKMS" -MachineState Velostrata -DeleteScriptFile