mirror of
https://github.com/jamesstringerparsec/Easy-GPU-PV.git
synced 2024-08-30 18:22:17 +00:00
Allow user to specify VHD Path
This commit is contained in:
parent
f9798704a4
commit
2b9638a6c5
@ -8,6 +8,7 @@
|
|||||||
MemoryAmount = 8GB
|
MemoryAmount = 8GB
|
||||||
CPUCores = 4
|
CPUCores = 4
|
||||||
NetworkSwitch = "Default Switch"
|
NetworkSwitch = "Default Switch"
|
||||||
|
VHDPath = "C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\"
|
||||||
UnattendPath = "$PSScriptRoot"+"\autounattend.xml"
|
UnattendPath = "$PSScriptRoot"+"\autounattend.xml"
|
||||||
GPUName = "AUTO"
|
GPUName = "AUTO"
|
||||||
GPUResourceAllocationPercentage = 50
|
GPUResourceAllocationPercentage = 50
|
||||||
@ -36,6 +37,19 @@ param(
|
|||||||
Dismount-DiskImage -DevicePath $mountResult.DevicePath | Out-Null
|
Dismount-DiskImage -DevicePath $mountResult.DevicePath | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function ConcatenateVHDPath {
|
||||||
|
param(
|
||||||
|
[string]$VHDPath,
|
||||||
|
[string]$VMName
|
||||||
|
)
|
||||||
|
if ($VHDPath[-1] -eq '\') {
|
||||||
|
$VHDPath + $VMName + ".vhdx"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$VHDPath + "\" + $VMName + ".vhdx"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Function SmartExit {
|
Function SmartExit {
|
||||||
param (
|
param (
|
||||||
[switch]$NoHalt,
|
[switch]$NoHalt,
|
||||||
@ -62,9 +76,13 @@ Function Check-Params {
|
|||||||
|
|
||||||
$ExitReason = @()
|
$ExitReason = @()
|
||||||
|
|
||||||
|
|
||||||
if ((Is-Administrator) -eq $false) {
|
if ((Is-Administrator) -eq $false) {
|
||||||
$ExitReason += "Script not running as Administrator, please run script as Administrator."
|
$ExitReason += "Script not running as Administrator, please run script as Administrator."
|
||||||
}
|
}
|
||||||
|
if (!(Test-Path $params.VHDPath)) {
|
||||||
|
$ExitReason += "VHDPath Directory doesn't exist, please create it before running this script."
|
||||||
|
}
|
||||||
if (!(test-path $params.SourcePath)) {
|
if (!(test-path $params.SourcePath)) {
|
||||||
$ExitReason += "ISO Path Invalid. Please enter a valid ISO Path in the SourcePath section of Params."
|
$ExitReason += "ISO Path Invalid. Please enter a valid ISO Path in the SourcePath section of Params."
|
||||||
}
|
}
|
||||||
@ -4287,7 +4305,7 @@ param(
|
|||||||
[int64]$SizeBytes,
|
[int64]$SizeBytes,
|
||||||
[int]$Edition,
|
[int]$Edition,
|
||||||
[string]$VhdFormat,
|
[string]$VhdFormat,
|
||||||
[string]$VhdPath = "C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\$($VMName).vhdx",
|
[string]$VhdPath,
|
||||||
[string]$VMName,
|
[string]$VMName,
|
||||||
[string]$DiskLayout,
|
[string]$DiskLayout,
|
||||||
[string]$UnattendPath,
|
[string]$UnattendPath,
|
||||||
@ -4303,7 +4321,8 @@ param(
|
|||||||
[string]$password,
|
[string]$password,
|
||||||
[string]$autologon
|
[string]$autologon
|
||||||
)
|
)
|
||||||
|
$VHDPath = ConcatenateVHDPath -VHDPath $VHDPath -VMName $VMName
|
||||||
|
|
||||||
if ($(Get-VM -Name $VMName -ErrorAction SilentlyContinue) -ne $NULL) {
|
if ($(Get-VM -Name $VMName -ErrorAction SilentlyContinue) -ne $NULL) {
|
||||||
SmartExit -ExitReason "Virtual Machine already exists with name $VMName, please delete existing VM or change VMName"
|
SmartExit -ExitReason "Virtual Machine already exists with name $VMName, please delete existing VM or change VMName"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user