43 lines
1.4 KiB
PowerShell
43 lines
1.4 KiB
PowerShell
$imageUrl = "http://www.ngtech.co.il/static/cloud-images/jammy-server-cloudimg-amd64.vhdx"
|
|
$seedUrl = "http://10.50.1.100/config/c3d16106-8ba0-4a9e-a1c1-e4d32b841503/c3d16106-8ba0-4a9e-a1c1-e4d32b841503-cloud-init-data.iso"
|
|
$imageFileName = "jammy-server-cloudimg-amd64.vhdx"
|
|
|
|
$user = "c3d16106-8ba0-4a9e-a1c1-e4d32b841503_px"
|
|
$password = "6a543ecd-0114-4d44-a599-36903008709f"
|
|
|
|
$vmnet = "DigitalyOcean_Cloud1"
|
|
|
|
$userPassPair = $user + ":" + $password
|
|
|
|
$vmdisk = ".\px-sys-disk.vhdx"
|
|
|
|
$vmseed = ".\seed.iso"
|
|
|
|
$vmname = "DIGITALOCEAN_c3d16106-8ba0-4a9e-a1c1-e4d32b841503"
|
|
|
|
|
|
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 ..
|