Turn off monitor PowerShell
Use the following PowerShell script to turn off monitor(s):
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class MonitorPower {
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
const int HWND_BROADCAST = 0xffff;
const int WM_SYSCOMMAND = 0x0112;
const int SC_MONITORPOWER = 0xF170;
public static void Off() {
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
}
}
"@ -Language CSharp
[MonitorPower]::Off()