diff --git a/src/lib/Get-HardwareInfo.psm1 b/src/lib/Get-HardwareInfo.psm1 index 322dbf8f..42340530 100644 --- a/src/lib/Get-HardwareInfo.psm1 +++ b/src/lib/Get-HardwareInfo.psm1 @@ -98,6 +98,22 @@ function Get-DriveSpace() { return "$DriveLetter`: $($AvailableStorage.ToString("#.#"))/$($TotalStorage.ToString("#.#")) GB ($((($AvailableStorage / $TotalStorage) * 100).ToString("#.#"))%)" } +function Get-PCSystemType() { + [CmdletBinding()] + + $PCSystemType = Get-CimInstance -Class Win32_ComputerSystem | Select-Object -ExpandProperty PCSystemType + + If ($PCSystemType -eq 1) { + Write-Status -Types "@", "Info" -Status "Your PC is a Desktop ($PCSystemType)" -Warning + } ElseIf ($PCSystemType -eq 2) { + Write-Status -Types "@", "Info" -Status "Your PC is a Laptop ($PCSystemType)" -Warning + } Else { + Write-Status -Types "?", "Info" -Status "Your PC system type is Unknown ($PCSystemType)" -Warning + } + + return $PCSystemType +} + function Get-SystemSpec() { [CmdletBinding()] [OutputType([System.Object[]])] diff --git a/src/scripts/Optimize-Performance.ps1 b/src/scripts/Optimize-Performance.ps1 index 6e081bd4..80a02872 100644 --- a/src/scripts/Optimize-Performance.ps1 +++ b/src/scripts/Optimize-Performance.ps1 @@ -1,4 +1,5 @@ Import-Module -DisableNameChecking "$PSScriptRoot\..\lib\Open-File.psm1" +Import-Module -DisableNameChecking "$PSScriptRoot\..\lib\Get-HardwareInfo.psm1" Import-Module -DisableNameChecking "$PSScriptRoot\..\lib\Title-Templates.psm1" Import-Module -DisableNameChecking "$PSScriptRoot\..\lib\Unregister-DuplicatedPowerPlan.psm1" Import-Module -DisableNameChecking "$PSScriptRoot\..\lib\debloat-helper\Set-ItemPropertyVerified.psm1" @@ -32,6 +33,7 @@ function Optimize-Performance() { ) } + $PCSystemType = Get-PCSystemType # Initialize all Path variables used to Registry Tweaks $PathToLMMultimediaSystemProfile = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile" $PathToLMMultimediaSystemProfileOnGameTasks = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games" @@ -80,8 +82,14 @@ function Optimize-Performance() { Write-Section "Power Plan Tweaks" - Write-Status -Types "+", $TweakType -Status "Setting Power Plan to High Performance..." - powercfg -SetActive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c + If ($PCSystemType -eq 1) { + Write-Status -Types "+", $TweakType -Status "Desktop ($PCSystemType): Setting Power Plan to High Performance..." + powercfg -SetActive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c + } ElseIf ($PCSystemType -eq 2) { + Write-Status -Types "@", $TweakType -Status "Laptop ($PCSystemType): Keeping current power plan..." -Warning + } Else { + Write-Status -Types "@", $TweakType -Status "Unknown ($PCSystemType): Keeping current power plan..." -Warning + } Write-Status -Types "+", $TweakType -Status "Creating the Ultimate Performance hidden Power Plan..." powercfg -DuplicateScheme e9a42b02-d5df-448d-aa00-03f14749eb61