-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathAdd-VirtioDrivers.ps1
55 lines (41 loc) · 1.42 KB
/
Add-VirtioDrivers.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#Requires -RunAsAdministrator
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$VirtioIsoPath,
[Parameter(Mandatory=$true)]
[string]$ImagePath,
[Parameter(Mandatory=$true)]
[ValidateSet('Server2025Datacenter',
'Server2025Standard',
'Server2022Datacenter',
'Server2022Standard',
'Server2019Datacenter',
'Server2019Standard',
'Server2016Datacenter',
'Server2016Standard',
'Windows11Enterprise',
'Windows11Professional',
'Windows10Enterprise',
'Windows10Professional',
'Windows81Professional')]
[string]$Version,
[int]$ImageIndex = 1
)
$ErrorActionPreference = 'Stop'
#
# Main
#
# Reference: https://pve.proxmox.com/wiki/Windows_10_guest_best_practices
. .\tools\Virtio-Functions.ps1
With-IsoImage -IsoFileName $VirtioIsoPath {
Param($virtioDriveLetter)
# Throws if the ISO does not contain Virtio drivers.
$virtioDrivers = Get-VirtioDrivers -VirtioDriveLetter $virtioDriveLetter -Version $Version
With-WindowsImage -ImagePath $ImagePath -ImageIndex $ImageIndex -VirtioDriveLetter $VirtioDriveLetter {
Param($mountPath)
$virtioDrivers | ForEach-Object {
Add-WindowsDriver -Path $mountPath -Driver $_ -Recurse -ForceUnsigned > $null
}
}
}