Fixed the typing in all advanced functions
- Removed empty End {} blocks - Removed Mandatory = $false parameters - Added SupportsShouldProcess where supported - Rename show-dialog-window.psm1 to show-message-dialog.psm1 - Move ui-helper, select-folder-gui and show-message-dialog to the "ui" subfolder - Don't display the BGR color anymore on new-system-color - Used Begin { } and Process { } blocks where needed - Updated all imports where neededmain
parent
e55156553a
commit
2b82728641
@ -1,5 +1,11 @@
|
||||
function Set-ConsoleStyle() {
|
||||
[CmdletBinding()] param ()
|
||||
[CmdletBinding()] param (
|
||||
[Parameter(Position = 0)]
|
||||
[ValidateSet(1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F')]
|
||||
[String] $Color = 'A'
|
||||
)
|
||||
|
||||
cmd /c color A
|
||||
}
|
||||
Process {
|
||||
cmd /c color $Color
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +1,40 @@
|
||||
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"title-templates.psm1"
|
||||
|
||||
function Unregister-DuplicatedPowerPlan() {
|
||||
$ExistingPowerPlans = $((powercfg -L)[3..(powercfg -L).Count])
|
||||
# Found on the registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\Default\PowerSchemes
|
||||
$BuiltInPowerPlans = @{
|
||||
"Power Saver" = "a1841308-3541-4fab-bc81-f71556f20b4a"
|
||||
"Balanced (recommended)" = "381b4222-f694-41f0-9685-ff5bb260df2e"
|
||||
"High Performance" = "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c"
|
||||
"Ultimate Performance" = "e9a42b02-d5df-448d-aa00-03f14749eb61"
|
||||
Begin {
|
||||
$ExistingPowerPlans = $((powercfg -L)[3..(powercfg -L).Count])
|
||||
# Found on the registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\Default\PowerSchemes
|
||||
$BuiltInPowerPlans = @{
|
||||
"Power Saver" = "a1841308-3541-4fab-bc81-f71556f20b4a"
|
||||
"Balanced (recommended)" = "381b4222-f694-41f0-9685-ff5bb260df2e"
|
||||
"High Performance" = "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c"
|
||||
"Ultimate Performance" = "e9a42b02-d5df-448d-aa00-03f14749eb61"
|
||||
}
|
||||
$UniquePowerPlans = $BuiltInPowerPlans.Clone()
|
||||
}
|
||||
$UniquePowerPlans = $BuiltInPowerPlans.Clone()
|
||||
|
||||
Write-Status -Types "@" -Status "Cleaning up duplicated Power plans..."
|
||||
ForEach ($PowerCfgString in $ExistingPowerPlans) {
|
||||
$PowerPlanGUID = $PowerCfgString.Split(':')[1].Split('(')[0].Trim()
|
||||
$PowerPlanName = $PowerCfgString.Split('(')[-1].Replace(')', '').Trim()
|
||||
Process {
|
||||
Write-Status -Types "@" -Status "Cleaning up duplicated Power plans..."
|
||||
ForEach ($PowerCfgString in $ExistingPowerPlans) {
|
||||
$PowerPlanGUID = $PowerCfgString.Split(':')[1].Split('(')[0].Trim()
|
||||
$PowerPlanName = $PowerCfgString.Split('(')[-1].Replace(')', '').Trim()
|
||||
|
||||
If (($PowerPlanGUID -in $BuiltInPowerPlans.Values)) {
|
||||
Write-Status -Types "@" -Status "The '$PowerPlanName' power plan is built-in, skipping $PowerPlanGUID..." -Warning
|
||||
Continue
|
||||
}
|
||||
If (($PowerPlanGUID -in $BuiltInPowerPlans.Values)) {
|
||||
Write-Status -Types "@" -Status "The '$PowerPlanName' power plan is built-in, skipping $PowerPlanGUID..." -Warning
|
||||
Continue
|
||||
}
|
||||
|
||||
Try {
|
||||
If (($PowerPlanName -notin $UniquePowerPlans.Keys) -and ($PowerPlanGUID -notin $UniquePowerPlans.Values)) {
|
||||
$UniquePowerPlans.Add($PowerPlanName, $PowerPlanGUID)
|
||||
} Else {
|
||||
Try {
|
||||
If (($PowerPlanName -notin $UniquePowerPlans.Keys) -and ($PowerPlanGUID -notin $UniquePowerPlans.Values)) {
|
||||
$UniquePowerPlans.Add($PowerPlanName, $PowerPlanGUID)
|
||||
} Else {
|
||||
Write-Status -Types "-" -Status "Duplicated '$PowerPlanName' power plan found, deleting $PowerPlanGUID..."
|
||||
powercfg -Delete $PowerPlanGUID
|
||||
}
|
||||
} Catch {
|
||||
Write-Status -Types "-" -Status "Duplicated '$PowerPlanName' power plan found, deleting $PowerPlanGUID..."
|
||||
powercfg -Delete $PowerPlanGUID
|
||||
}
|
||||
} Catch {
|
||||
Write-Status -Types "-" -Status "Duplicated '$PowerPlanName' power plan found, deleting $PowerPlanGUID..."
|
||||
powercfg -Delete $PowerPlanGUID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue