Skip to content

Doesn't work if invoked in non-interactive mode #4

@Dvvarf

Description

@Dvvarf

Hello,

First of all, thanks a lot for the module!

I'm having an issue trying to run it in non-interactive mode (as SYSTEM user) though. I get the following error:

Failed to get the number of physical monitors attached to 'WinDisc'.
    + CategoryInfo          : NotSpecified: (WinDisc:LogicalDisplay) [Get-Monitor], ApiException
    + FullyQualifiedErrorId : GetPhysicalMonitors,MartinGC94.MonitorConfig.Commands.GetMonitorCommand
    + PSComputerName        : localhost

I'm trying to use this module in a scheduled task and can reproduce this error by using Invoke-CommandAs module:

Invoke-CommandAs -ScriptBlock { Get-Monitor } -AsSystem

I've also tried fetching specific monitor, but to no avail -- in this case there is no error, but no return as well:

Invoke-CommandAs -ScriptBlock { Get-Monitor -DeviceName "\\.\DISPLAY1" } -AsSystem

I understand that there is a high chance it's not possible to get monitor information in non-interactive mode, since there is no window/display handle available. However, perhaps there is some way?

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions