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

Get-Window

Synopsis

Gets the application windows that are open on the local desktop.

Syntax

  • Get-Window [-Process] [-ShowBackgroundWindows]
  • Get-Window [-Title] [-ShowBackgroundWindows]
  • Get-Window [-ProcessID] [-ShowBackgroundWindows]

Description

The Get-Window cmdlet gets the application windows that are open on the local desktop.

Without parameters Get-Window returns all of the currently open top level windows (a top level window being a window to an application that is not a dialog box and is visible to the user). You can also get specific top level windows by specifying the title of the window, the process name or process ID of the associated application.

Parameters

  • Process Return windows associated with this process name.
  • ShowBackgroundWindow Show top level windows that are not necessarily visible to the user.
  • Title Return windows with this title.
  • ProcessID Return window associated with this process ID.

Inputs

Get-Window accepts the output of Get-Process as an input object.

Outputs

Get-Window returns a Vexasoft.AppWindow object with details of the current window state and associated Windows application.

Notes

There are no notes associated with the Get-Window cmdlet.

Example 1

This command will get all open application windows on the current desktop:

C:\PS>Get-Window

Example 2

This command will get all open application windows on the current desktop and any background windows that the applications are holding:

C:\PS>Get-Window -ShowBackgroundWindows

Example 3

This command will get any windows on the current desktop that belong to the Outlook application:

C:\PS>Get-Window outlook

Example 4

This command will get any windows that are open and associated with PID 5592:

C:\PS>Get-Window -ProcessID 5592

Example 5

This command will get any windows with the title "Untitled - Notepad":

C:\PS>Get-Window -Title "Untitled - Notepad"

Example 6

Get-Window can work in conjunction with the Get-Process cmdlet. This command will fetch any PowerShell processes running on the local computer and return any associated windows that are visible to the local user:

C:\PS>Get-Process *powershell* | Get-Window