指定時間後にSuspend
指定した時間の後にWindowsをサスペンドするためのスクリプト。参照先は以下。
<#
.SYNOPSIS
Suspend PC
.PARAMETER sleep
specifies waiting seconds to suspend.
.DESCRIPTION
The followings are steps to suspend this PC.
1.Define the power state you wish to set, from the System.Windows.Forms.PowerState enumeration.
2.Define whether or not to force the power state
3.Define whether or not to disable wake capabilities
4.Set the power state
5.Execute
Refer from https://stackoverflow.com/questions/20713782/suspend-or-hibernate-from-powershell
#>
Param(
[Int]$sleep = 0
)
Start-Sleep -s $sleep
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$PowerState = [System.Windows.Forms.PowerState]::Suspend;
$Force = $true;
$DisableWake = $false;
[System.Windows.Forms.Application]::SetSuspendState($PowerState, $Force, $DisableWake);
これで以下のコマンドで1時間後にスリープする。
.\suspend.ps1 -sleep 3600