This cmdlet is part of the Vexasoft Cmdlet Library. You can download it now or click here to find out more.

Set-WindowState

Synopsis

Minimize, maximize or restore the specified window on the local desktop.

Syntax

  • Set-WindowState [-Window] [-Minimize] [-Maximize] [-Restore] [-ShowDefault]

Description

The Set-WindowState cmdlet is used to minimize, maximize or restore an application window that is open on the local desktop.

Send-KeyboardInput requires that you use the Get-Window cmdlet to identify the target application window.

Parameters

  • Window The target application window. AppWindow objects are generated using the Get-Window cmdlet.
  • Minimize Minimize the window.
  • Maximize Maximize the window.
  • Restore Restore the window to its previous non-minimized or maximized size and location.
  • ShowDefault Set the window to its default size and location.

Inputs

Set-WindowState must be used in conjunction with the Get-Window cmdlet and accepts the output of Get-Window as an input object.

Outputs

Set-WindowState does not return any PowerShell objects.

Notes

There are no notes associated with the Set-WindowState cmdlet.

Example 1

Set-WindowState must be used in conjunction with the Get-Window cmdlet.

This command will minimize the PowerShell window:

C:\PS>Get-Window powershell | Set-WindowState -Minimize

Example 2

This command will put a minimized or maximized PowerShell window back to its original position:

C:\PS>Get-Window powershell | Set-WindowState -Restore

Example 3

This command will put a minimized or maximized PowerShell window back to its default position:

C:\PS>Get-Window powershell | Set-WindowState -ShowDefault