For the first one (power cable plugged/unplugged), have a look to Win32_PowerManagementEvent class ; you can use :
Register-WmiEvent -Query "select * from Win32_PowerManagementEvent" -MessageData "Event Power by JPB" -SourceIdentifier "EVTPOW1"
Wait-Event -SourceIdentifier "EVTPOW1"
Or
Register-WmiEvent -Query "select * from Win32_PowerManagementEvent" -SourceIdentifier "EVTPOW2" -Action {Write-Host "blurp"; [console]::Beep(500,500)}
In the second case you put in your script block the code you need.