Powershell - Changing the state of a computer (sleep, hibernate, shutdown, restart)
To support me, you can subscribe to the channel, share and like the videos, disable your ad blocker or make a donation. Thank you!
Hello,
A new article to show how to change the state of a computer (sleep, hibernate, shutdown, reboot) with Powershell. The forced option is useful if, for example, a user session is open and prevents the action (boot…) from taking place.
# Put to sleepAdd-Type -Assembly System.Windows.Forms[System.Windows.Forms.Application]::SetSuspendState(‘Suspend’, $false, $false)
# Force to sleepAdd-Type -Assembly System.Windows.Forms[System.Windows.Forms.Application]::SetSuspendState(‘Suspend’, $true, $false)
# Put into hibernationAdd-Type -Assembly System.Windows.Forms[System.Windows.Forms.Application]::SetSuspendState(‘Hibernate’, $false, $false)
# Force HibernateAdd-Type -Assembly System.Windows.Forms[System.Windows.Forms.Application]::SetSuspendState(‘Hibernate’, $true, $false)
# RestartRestart-Computer
# Force restartRestart-Computer -Force
# StopStop-Computer
# Force stopStop-Computer -Force
Related links
Powershell - Simply send objects to different variables
Powershell - Tip - Simply send objects to different variablesPowershell - Testing network connectivity and port accessibility
Testing network connectivity and port accessibility with PowershellPowershell - Display network connections (equivalent to netstat)
Display network connections (listening ports, active connections...)Powershell - Testing name resolution (equivalent to nslookup)
Powershell commands to test name resolution (equivalent to nslookup)Powershell - View and manage DNS configuration of network interfaces
Powershell commands to display and manage DNS configuration of network interfacesPowershell - Managing IP configuration of network interfaces
Powershell commands to view and modify the IP configuration of network interfaces