1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
080d0e5f1c created variables for easy switching of PCIe paths 2023-03-31 15:25:46 +02:00
89350ee4e2 Add Readme 2023-03-31 15:22:07 +02:00
4 changed files with 65 additions and 59 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# How to run
Change PCIe paths in file
Execute switchGPU.ps1 in powershell

View File

@ -1,6 +1,9 @@
param([String]$working=$pwd, [String]$desktop = [Environment]::GetFolderPath("Desktop")) param([String]$working=$pwd, [String]$desktop = [Environment]::GetFolderPath("Desktop"))
$folderPath = "C:\.gpu" $iGPUpci = "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041"
$gpuTask = Join-Path $working GPU.xml $dGPUpci = "PCI\VEN_10DE&DEV_1B80&SUBSYS_85AA1043&REV_A1\6&5c8cf2c&0&00080019"
$folderPath = "C:\.gpu" #do not change unless you change it in GPU.xml as well
$gpuTask = Join-Path $working GPU.xml #just do not change
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" -working $pwd -desktop $desktop" -Verb RunAs; exit } if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" -working $pwd -desktop $desktop" -Verb RunAs; exit }
$scriptOld = Join-Path $working "*" $scriptOld = Join-Path $working "*"
@ -32,13 +35,13 @@ if(Get-ScheduledTask | Where-Object{$_.TaskName -eq "GPU"})
Write-Output "Waiting 5 Seconds" Write-Output "Waiting 5 Seconds"
Start-Sleep 5 Start-Sleep 5
if(Get-PnpDevice | Where-Object{$_.InstanceId -eq "PCI\VEN_10DE&DEV_1B80&SUBSYS_85AA1043&REV_A1\6&5c8cf2c&0&00080019"} | Where-Object{$_.Status -eq "OK"}) if(Get-PnpDevice | Where-Object{$_.InstanceId -eq $dGPUpci} | Where-Object{$_.Status -eq "OK"})
{ {
Write-Output "dGPU plugged in" Write-Output "dGPU plugged in"
if(Get-PnpDevice | Where-Object{$_.InstanceId -eq "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041"} | Where-Object{$_.Status -eq "OK"}) if(Get-PnpDevice | Where-Object{$_.InstanceId -eq $iGPUpci} | Where-Object{$_.Status -eq "OK"})
{ {
Write-Output "Disabling iGPU" Write-Output "Disabling iGPU"
pnputil /disable-device "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041" #disable iGPU pnputil /disable-device $iGPUpci #disable iGPU
}else }else
{ {
Write-Output "iGPU already disabled" Write-Output "iGPU already disabled"
@ -46,12 +49,12 @@ if(Get-PnpDevice | Where-Object{$_.InstanceId -eq "PCI\VEN_10DE&DEV_1B80&SUBSYS_
}else }else
{ {
Write-Output "dGPU not plugged in" Write-Output "dGPU not plugged in"
if(Get-PnpDevice | Where-Object{$_.InstanceId -eq "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041"} | Where-Object{$_.Status -eq "OK"}) if(Get-PnpDevice | Where-Object{$_.InstanceId -eq $iGPUpci} | Where-Object{$_.Status -eq "OK"})
{ {
Write-Output "iGPU already enabled" Write-Output "iGPU already enabled"
}else }else
{ {
Write-Output "Enabling iGPU" Write-Output "Enabling iGPU"
pnputil /enable-device "PCI\VEN_1002&DEV_1681&SUBSYS_380117AA&REV_C1\4&33381BD1&0&0041" #enable iGPU pnputil /enable-device $iGPUpci #enable iGPU
} }
} }