Script to detect and clone display
function Set-Display
{
param(
[Parameter(Position=0)]
[ValidateSet('external','internal','clone','extend','gui')]
[string]$Mode='gui'
)
$path = Join-Path -Path ([environment]::SystemDirectory) -ChildPath DisplaySwitch.exe
if( !(Test-Path -Path $path -PathType Leaf))
{
throw "Cannot find DisplaySwitch.exe"
}
if($Mode -eq 'gui')
{
& $path
}
else
{
& $path /$Mode
}
}
PS > Set-Display -Mode clone