-
Notifications
You must be signed in to change notification settings - Fork 436
/
PreChecks.ps1
65 lines (58 loc) · 2.18 KB
/
PreChecks.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
56
57
58
59
60
61
62
63
64
65
Function Get-DesktopPC
{
$isDesktop = $true
if(Get-WmiObject -Class win32_systemenclosure | Where-Object { $_.chassistypes -eq 9 -or $_.chassistypes -eq 10 -or $_.chassistypes -eq 14})
{
Write-Warning "Computer is a laptop. Laptop dedicated GPU's that are partitioned and assigned to VM may not work with Parsec."
Write-Warning "Thunderbolt 3 or 4 dock based GPU's may work"
$isDesktop = $false }
if (Get-WmiObject -Class win32_battery)
{ $isDesktop = $false }
$isDesktop
}
Function Get-WindowsCompatibleOS {
$build = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
if ($build.CurrentBuild -ge 19041 -and ($($build.editionid -like 'Professional*') -or $($build.editionid -like 'Enterprise*') -or $($build.editionid -like 'Education*'))) {
Return $true
}
Else {
Write-Warning "Only Windows 10 20H1 or Windows 11 (Pro or Enterprise) is supported"
Return $false
}
}
Function Get-HyperVEnabled {
if (Get-WindowsOptionalFeature -Online | Where-Object FeatureName -Like 'Microsoft-Hyper-V-All'){
Return $true
}
Else {
Write-Warning "You need to enable Virtualisation in your motherboard and then add the Hyper-V Windows Feature and reboot"
Return $false
}
}
Function Get-WSLEnabled {
if ((wsl -l -v)[2].length -gt 1 ) {
Write-Warning "WSL is Enabled. This may interferre with GPU-P and produce an error 43 in the VM"
Return $true
}
Else {
Return $false
}
}
Function Get-VMGpuPartitionAdapterFriendlyName {
$Devices = (Get-WmiObject -Class "Msvm_PartitionableGpu" -ComputerName $env:COMPUTERNAME -Namespace "ROOT\virtualization\v2").name
Foreach ($GPU in $Devices) {
$GPUParse = $GPU.Split('#')[1]
Get-WmiObject Win32_PNPSignedDriver | where {($_.HardwareID -eq "PCI\$GPUParse")} | select DeviceName -ExpandProperty DeviceName
}
}
If ((Get-DesktopPC) -and (Get-WindowsCompatibleOS) -and (Get-HyperVEnabled)) {
"System Compatible"
"Printing a list of compatible GPUs...May take a second"
"Copy the name of the GPU you want to share..."
Get-VMGpuPartitionAdapterFriendlyName
Read-Host -Prompt "Press Enter to Exit"
}
else {
Read-Host -Prompt "Press Enter to Exit"
}