Чтобы иметь синтаксически правильный скрипт powershell:
#retrive virtual Screen with to compare to working area Add-Type -Assembly System.Windows.Forms $VSW = [System.Windows.Forms.SystemInformation]::VirtualScreen.Width $WAW = [System.Windows.Forms.SystemInformation]::WorkingArea.width #comparing and chose diplay option if (%WAW% -le %VSW%){ displayswitch.exe /clone ) else { displayswitch.exe /extend }
Но это не будет (хорошо) работать, например, в системах с двумя мониторами или с боковой панелью.