###############################################################
# @description:                                               #
#   Used to create a new ScheduledTask                        #
#   The task will run as System, wil wake up from sleep       #     
#   and will run if system is on bateriess                    #
#                                                             #
# @author: Bram Prieshof                                      #
###############################################################

$action =  New-ScheduledTaskAction -Execute <Command> -Argument "<Args>"
$trigger =  New-ScheduledTaskTrigger -At 18:00 -Daily
$options = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -DontStopOnIdleEnd -WakeToRun 
$principal = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest
Register-ScheduledTask -TaskName AutoPowerOff -Trigger $trigger -Action $action -Settings $options -Principal $principal