Some servers need to shutdown to conserve power - its our only planet!
function Create-Shutdown-Scheduled-Task()
{
#create a scheduled taks that will shutdown the VM after 5 mins, at 7pm
$action = New-ScheduledTaskAction -Execute 'C:\Windows\System32\shutdown.exe' -Argument ' /s /t 1 /f /c "shutting down for the day..."'
$trigger = New-ScheduledTaskTrigger -Daily -At 7pm
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "Automated Shutdown" -Description "Business policy is to shutdown VMs at 7pm daily" -User "$env:USERDOMAIN\$env:USERNAME" -Password 'DWProduct@1'
}
Create-Shutdown-Scheduled-Task
No comments:
Post a Comment