mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-12 08:58:16 +01:00
Add some VM scripts
This commit is contained in:
parent
587c0824b9
commit
9f56234f99
4
scripts/import-vm.ps1
Normal file
4
scripts/import-vm.ps1
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
$VMName = "debian"
|
||||||
|
Get-ChildItem "C:\packer\$VMName\Virtual Machines\*.vmcx" | Import-VM -Copy -VhdDestinationPath "C:\VirtualMachines\$VMName\Virtual Hard Disks" -VirtualMachinePath "C:\VirtualMachines\$VMName" -GenerateNewId
|
||||||
|
Start-VM $VMName
|
||||||
|
exit 0 # success
|
3
scripts/move-vm.ps1
Normal file
3
scripts/move-vm.ps1
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
$VMName = "windows"
|
||||||
|
Move-VM $VMName HOST2 -IncludeStorage -DestinationStoragePath "D:\VirtualMachines\$VMName"
|
||||||
|
exit 0 # success
|
19
scripts/new-linux-vm.ps1
Normal file
19
scripts/new-linux-vm.ps1
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
$VMName = "linux"
|
||||||
|
|
||||||
|
$VM = @{
|
||||||
|
Name = $VMName
|
||||||
|
MemoryStartupBytes = 1GB
|
||||||
|
Generation = 2
|
||||||
|
NewVHDPath = "C:\VirtualMachines\$VMName\Virtual Hard Disks\$VMName.vhdx"
|
||||||
|
NewVHDSizeBytes = 30GB
|
||||||
|
BootDevice = "VHD"
|
||||||
|
Path = "C:\VirtualMachines\"
|
||||||
|
SwitchName = 'vSwitch'
|
||||||
|
}
|
||||||
|
|
||||||
|
New-VM @VM
|
||||||
|
Set-VMProcessor $VMName -count 1
|
||||||
|
Add-VMDvdDrive $VMName
|
||||||
|
Set-VMDvdDrive $VMName -Path "C:\iso\CentOS-8.3.2011-x86_64-minimal.iso"
|
||||||
|
Set-VMFirmware -EnableSecureBoot Off $VMName
|
||||||
|
exit 0 # success
|
18
scripts/new-windows-vm.ps1
Normal file
18
scripts/new-windows-vm.ps1
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
$VMName = "windows"
|
||||||
|
|
||||||
|
$VM = @{
|
||||||
|
Name = $VMName
|
||||||
|
MemoryStartupBytes = 4GB
|
||||||
|
Generation = 2
|
||||||
|
NewVHDPath = "C:\VirtualMachines\$VMName\Virtual Hard Disks\$VMName.vhdx"
|
||||||
|
NewVHDSizeBytes = 50GB
|
||||||
|
BootDevice = "VHD"
|
||||||
|
Path = "C:\VirtualMachines\"
|
||||||
|
SwitchName = 'vSwitch'
|
||||||
|
}
|
||||||
|
|
||||||
|
New-VM @VM
|
||||||
|
Set-VMProcessor $VMName -count 1
|
||||||
|
Add-VMDvdDrive $VMName
|
||||||
|
Set-VMDvdDrive $VMName -Path "C:\iso\Win10_21H1_English_x64.iso"
|
||||||
|
exit 0 # success
|
6
scripts/remove-vm.ps1
Normal file
6
scripts/remove-vm.ps1
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
$VMName = "debian"
|
||||||
|
$WarningPreference = 'SilentlyContinue' # If VM already stopped
|
||||||
|
Stop-VM $VMName -Force
|
||||||
|
Remove-VM $VMName -Force
|
||||||
|
Remove-Item -Path "C:\VirtualMachines\$VMName" -Recurse
|
||||||
|
exit 0 # success
|
Loading…
Reference in New Issue
Block a user