Powershell - Detect current Primary monitor and resolution as SYSTEM account
Budget: $10 – $30 USD
Scenario, multiple monitors are connected to a Windows PC. Detect the primary monitor and resolution using powershell code. Must be ran as "SYSTEM" account to detect with no user interaction.
The following powershell code works under the "User context" but does not work as system account. (returns wrong resolutions)
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Screen]::AllScreens
I'm after it running under a system context. Can be via WMI/Registry key etc.
To run as a system context the following can be ran to test code: psexec -s powershell
The following powershell code works under the "User context" but does not work as system account. (returns wrong resolutions)
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Screen]::AllScreens
I'm after it running under a system context. Can be via WMI/Registry key etc.
To run as a system context the following can be ran to test code: psexec -s powershell
Related categories:
Powershell