Running CI/CD Scripts on a Remote VM
October 3, 2025 ยท View on GitHub
This guide explains how to set up and run eBPF for Windows CI/CD scripts on a remote VM using WinRM.
Prepare the Remote VM
Set the execution policy and run the setup script as Administrator:
Set-ExecutionPolicy Unrestricted -Force
.\setup_remote_vm.ps1
Post reboot run winrm quickconfig and take a snapshot of the VM.
Start WinRM service on the local host
sc.exe start winrm
Ensure Remote VM is Reachable
On your host machine, verify that the remote VM is reachable and that WinRM is running by executing:
Test-WSMan <remote-vm-ip>
If this command fails, ensure the VM is powered on, network connectivity is working, and WinRM is enabled.
Add Remote VM to Trusted Hosts
On your host machine, allow connections to the remote VM by adding its IP address to the list of trusted hosts:
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "<remote-vm-ip>"
Store VM Credentials on the Host
On your host machine, save the VM administrator and standard user credentials using the CredentialManager module:
Install-Module CredentialManager -Force
New-StoredCredential -Target TEST_VM -Username <VM Administrator> -Password <VM Administrator account password> -Persist LocalMachine
New-StoredCredential -Target TEST_VM_STANDARD -Username <VM Standard User Name> -Password <VM Standard User account password> -Persist LocalMachine
Note: Use the literal names
TEST_VMandTEST_VM_STANDARDfor the credential targets. These do not need to match the actual VM names.
Prepare the Build Artifacts
-
Navigate to the Build Directory
cd .\x64\Debug # or cd .\x64\Release -
Edit
test_execution.jsonUpdate the
VMMapsection to specify your test VM. Example:{ ... "VMMap": { "<host name>": [ { "Name": "<test-vm-ip>" } ] } }Note:
<host name>refers to the name of your host machine. You can get this value by running[System.Net.Dns]::GetHostName()in PowerShell.
Run the CI/CD Setup Script
-
Run the Setup Script
.\setup_ebpf_cicd_tests.ps1 -VMIsRemote -
Run the Test Execution Script
.\execute_ebpf_cicd_tests.ps1 -VMIsRemote
Additional Notes
- The credentials stored in step 3 will be used for authentication to the VM during test execution.
- When running
setup_ebpf_cicd_tests.ps1on a Hyper-V VM, the script automatically reverts the VM to a baseline checkpoint before setting up the machine. However, when running the script on a remote VM, you must manually take a snapshot before running the setup script and revert to it after runningexecute_ebpf_cicd_tests.ps1. - If your goal is simply to deploy pre-built binaries to a remote virtual machine, you can use the deploy-ebpf.ps1 script instead. This script will prompt you for credentials during execution.
The script copies files to
c:\tempon the remote VM..\deploy-ebpf.ps1 --dir="c:\temp" --remote_vm=<remote-vm-ip>