Last active
July 27, 2017 09:50
-
-
Save Stephanevg/5e345eb976da1eb276384b694fe8e5cd to your computer and use it in GitHub Desktop.
VSCODE BUG: Code blocks do not close correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Write-ChangeLog { | |
[Cmdletbinding()] | |
param ( | |
[Parameter(Mandatory=$true)][String]$Message | |
) | |
$ChangeLogWriter = "C:\Admin\Tools\ChangeLogWriter\ChangeLogWriter.exe" | |
if (Test-Path $ChangeLogWriter) { | |
Write-Log -Message "Write to the ChangeLogWriter" -Status INFO | |
Start-Process -FilePath $ChangeLogWriter -ArgumentList "/USER:$($env:username) /CONTENT:$($Message)" | |
} else { | |
Write-Log -Message "ChangeLogWriter.exe not found!" -Status WARN | |
} | |
} | |
function Manage-PowerPlan { | |
[cmdletbinding()] | |
Param( | |
[ValidateSet("High Performance","Balanced","Power saver")]$Activate, | |
[switch]$GetActive | |
) | |
switch ($PSBoundParameters.keys){ | |
"GetActive"{ | |
$activated = Get-CimInstance -Name "root\cimv2\power" -Class win32_PowerPlan -Filter "IsActive = $true" | |
return $activated | |
;Break | |
} | |
"Activate" { | |
write-verbose "Activating $($plantype)" | |
try{ | |
$plan = Get-CimInstance -Name "root\cimv2\power" -Class win32_PowerPlan -Filter "ElementName = '$($Activate)'" -ErrorAction Stop | |
$retvalue = Invoke-CimMethod -InputObject $plan -MethodName Activate -ErrorAction Stop | |
if ($retvalue.ReturnValue -eq $true){ | |
write-verbose "successfully enabled powerplan $($planType)" | |
}else{ | |
Write-Warning "Could not activate the powerplan $($planType)" | |
} | |
}catch{ | |
write-warning $_ | |
} | |
;Break | |
} | |
default { | |
Write-Warning "No parameters have been passed" | |
;break | |
} | |
}#end switch | |
}#end function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment