When a new screen is connected to a Windows machine, it doesn't create a specific log file. However, you can monitor the Event Viewer for display-related events or use WMI events to detect changes in the display configuration
check the Event Viewer for display-related events. Under "Applications and Services Logs" > "Microsoft" > "Windows" > "UserPnp" > "Operational," look for Event ID 20001, which indicates a display change.
or WMI
$wmiQuery = @"
SELECT * FROM __InstanceModificationEvent WITHIN 2
WHERE TargetInstance ISA 'Win32_DesktopMonitor'
"@
Register-WMIEvent -Query $wmiQuery -SourceIdentifier "DisplayChange" -Action {
Write-Host "Display configuration changed!"
# Your code or command to set the screen to extend mode
}