proxy-setup-spinner/vms/spin-afca9258-834c-4c5b-be3c-11a52ec7edbf_px.ps1
Eliezer Croitoru d7ec0d2317 1
2024-02-07 23:57:14 +02:00

43 lines
1.4 KiB
PowerShell

$imageUrl = "http://www.ngtech.co.il/static/cloud-images/debian-12-generic-amd64.vhdx"
$seedUrl = "http://10.50.1.100/config/afca9258-834c-4c5b-be3c-11a52ec7edbf/afca9258-834c-4c5b-be3c-11a52ec7edbf-cloud-init-data.iso"
$imageFileName = "debian-12-generic-amd64.vhdx"
$user = "afca9258-834c-4c5b-be3c-11a52ec7edbf_px"
$password = "aab51b40-0a9f-42bd-802a-7a23fcccade5"
$vmnet = "DigitalyOcean_Cloud1"
$userPassPair = $user + ":" + $password
$vmdisk = ".\px-sys-disk.vhdx"
$vmseed = ".\seed.iso"
$vmname = "DIGITALOCEAN_afca9258-834c-4c5b-be3c-11a52ec7edbf"
mkdir $vmname
cd $vmname
if ( Test-Path("..\images\" + $imageFileName)) {
Write-Output "Copying image locally"
Copy-Item ("..\images\" + $imageFileName) -Destination $vmdisk
Write-Output "Finished copying image locally"
} else {
Write-Output "Downloading image from a remote server"
Invoke-WebRequest -Uri $imageUrl -OutFile $vmdisk
Write-Output "Finished downloading image from a remote server"
}
Write-Output "Downloading seed image from a remote server"
Invoke-WebRequest -Uri $seedUrl -OutFile $vmseed -Headers @{ Authorization = "Basic "+ [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($userPassPair)) }
Write-Output "Finished downloading seed image from a remote server"
New-VM -Name $vmname -MemoryStartupBytes 2GB -Path . -BootDevice VHD -VHDPath $vmdisk -SwitchName $vmnet -Generation 1
Set-VMDvdDrive -VMName $vmname -Path $vmseed
Start-VM $vmname
cd ..