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:
The registry is updated to run the scripts (also known as
startup depending on the environment where the VM is running (also known as the
The three options for
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
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
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.
Available commands are:
To use the assistance script:
- Install the module.
- Download the PowerShell User Scripts from the Downloads page.
Import the module (use the correct path for your deployment):
Import-Module .\MigrateForGCEUserScripts.psm1 -force
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 GCPwhere:
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.
Velostrata- 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:
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
TaskNameis similar to the one provided during
DeleteScriptFileis 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