Log file for new Screen connection

Simon Amsler 0 Reputation points
2023-03-27T11:46:24.4933333+00:00

I need to know if there is a Log file, when a new Screen is being connected.

I need this to know if there is a special code or anything for that, so I can create a triggerpoint for a Task.

(The task is going to set the screen to extend)

Please let me know if you know something

PS: See this forum --> https://answers.microsoft.com/en-us/windows/forum/windows_10-hardware/log-file-for-new-screen-connection/dd159990-9616-4dc5-9f6c-874924123a7f

Already asked this question there got sent here for more infos

Thanks

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,360 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 12,820 Reputation points
    2023-03-27T12:30:08.7233333+00:00

    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
    }