Last evening my girl was mean to me… she told me that the “system administrator” today isn’t “god” anymore. Users are in control…and so was she! Or at least that is what she thought… mistake number one.
The people that know me understand that I see such a remark as a straight up challenge and are probably thinking something like “Omg Jeff, what the hell did you do next…?”.
I knew that she would have to work all evenings this weekend on a paper/report for her work which provides me with a beautiful chance…
Yes, there are tools to make this task way easier… but where’s the fun in that?
So, I started scripting… turning the laptop off is a little evil since she could loose some work. Turning the screen 90 degrees was my first idea, but was not able to get the script working.
Turning off the screen…what if I couldn’t get it on again and some of her work would be lost? No, turning off the screen wasn’t an option… but dimming the light is!
So, I started scripting and when I was finished I scheduled the script to run on my server at:
19:03, 19:06, 19:09, 19:20, 19:21, 19:23, 19:25, 19:27.
So… she was sitting behind one of my laptops working on some report while I was watching some TV. Yes, she was sitting behind one of MY laptops… mistake number two.
At 19:03 I heard some noise, but she seemed to found the setting in the GUI to correct the setting.
At 19:06 I heard some harder noise, and again she seemed to have used the GUI to correct it.
# Very much trying not to laugh…
At 19:10 I noticed that she gave the laptop a reboot.
# Like faith was helping me, just when I did not schedule the script, she did a reboot… *evil laugh*
At 19:14 the laptop was booted up and she was working again.
At 19:20 she made a very annoyed sound.
At 19:21 she looked at me very angry (could see it through the mirror).
# Still trying very hard not to cry out in laughter…
At 19:26 she told me that the system administrator was god…and if I could please STOP IT!!!
# Now I couldn’t hold it anymore… I started laughing and my belly still hurts from it…
Lesson: Never mess with a geek!
The following is the script I’ve used:
. $env:windir\diagnostics\system\power\powerconfig.ps1
function isAC {
(gwmi BatteryStatus -Namespace root\wmi).PowerOnline
}
function GetActiveSchemeGuid()
{
$activeSchemeGuid = [PowerConfig]::ActiveSchemeGuid()
return $activeSchemeGuid
}
function Get-VideoBrightness([bool]$isAC=$(isAC))
{
$activeSchemeGuid = $powerconfig::ActiveSchemeGuid()
$subGroupGuid = new-object system.Guid("7516b95f-f776-4464-8c53-06167f40cc99")
$settingGuid = new-object system.Guid("aded5e82-b909-4619-9949-f5d71dac0bcb")
$settingvalue = 0
$res = [PowerConfig]::ReadPowerSetting($isAC,[ref]$activeSchemeGuid,[ref]$subGroupGuid,[ref]$settingGuid,[ref]$settingvalue)
if($res -eq 0)
{
$settingvalue
}
}
function Get-DefaultVideoBrightness([bool]$isAC=$(isAC))
{
$BalancedPowerPlan = $powerconfig::BalancedPowerPlan()
$subGroupGuid = new-object system.Guid("7516b95f-f776-4464-8c53-06167f40cc99")
$settingGuid = new-object system.Guid("aded5e82-b909-4619-9949-f5d71dac0bcb")
$settingvalue = 0
$res = [PowerConfig]::ReadDefaultSetting($isAC,[ref]$BalancedPowerPlan,[ref]$subGroupGuid,[ref]$settingGuid,[ref]$settingvalue)
if($res -eq 0)
{
return $settingvalue
}
}
function Set-VideoBrightness([int]$settingvalue = 100, [bool]$isAC=$(isAC))
{
$activeSchemeGuid = $powerconfig::ActiveSchemeGuid()
$subGroupGuid = new-object system.Guid("7516b95f-f776-4464-8c53-06167f40cc99")
$settingGuid = new-object system.Guid("aded5e82-b909-4619-9949-f5d71dac0bcb")
[void][PowerConfig]::WritePowerSetting($isAC,[ref]$activeSchemeGuid,[ref]$subGroupGuid,[ref]$settingGuid,$settingvalue)
}
Get-VideoBrightness
Get-DefaultVideoBrightness
Set-VideoBrightness 1