Skip to content

Conversation

@b0tmtl
Copy link

@b0tmtl b0tmtl commented Jan 13, 2026

Generated with Copilot:

This pull request enhances the Set-ScreenResolution PowerShell function to support changing the screen resolution in remote sessions (such as via PowerShell remoting), and improves the robustness and flexibility of the script. The main update introduces an optional -AsTask parameter, which uses a scheduled task to perform the resolution change in the context of the interactive user—solving a common limitation when running scripts remotely.

Key changes:

Remote session support:

  • Added an optional [switch]$AsTask parameter to the Set-ScreenResolution function, enabling the use of a scheduled task to change resolution in remote or non-interactive sessions. [1] [2]
  • Implemented the Set-ResolutionViaScheduledTask helper function, which creates and runs a scheduled task under the interactive user, executes the resolution change, and retrieves the result. This includes script generation, task registration, execution, result collection, and cleanup. [1] [2]

General improvements:

  • Improved parameter formatting and handling in the Set-ScreenResolution function for readability and maintainability.
  • Added a check and dynamic loading of the Add-Type definition for the resolution-changing .NET type if not already loaded, improving script resilience.

Documentation:

  • Updated the README.md with an example showing how to use the new -AsTask parameter for remote sessions.

Added example for running Set-ScreenResolution in a remote session.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant