≡ Menu

PowerShell: Minimize all windows

Have you ever got a requirement to minimize all windows on the desktop using powershell script? It is helpful when you want to give a pop-up message to user which should draw their immediate attention.

I came across this little tip while exploring shell.application com object. It has other useful functions like undominimizeall, cascade windows, and many other explorer functions.

$shell = New-Object -ComObject "Shell.Application"
$shell.minimizeall()

You can also undo minimize all windows by using below code.

$shell = New-Object -ComObject "Shell.Application"
$shell.undominimizeall()

To see the clear functionality, add some delay between minimizeall() function and undominimizeall() function.

$shell = New-Object -ComObject "Shell.Application"
$shell.MinimizeAll()
start-sleep -Seconds 5
$shell.undominimizeall()

Hope this helps… You can explore more functions of shell.application object by using below code snippet.

New-Object -ComObject "Shell.Application" | gm | select Name, MemberType

Comments on this entry are closed.

  • Bikash Biswal November 12, 2017, 12:11 am

    I am looking for the method to minimize my PowerShell GUI windows. Is there any methods, could you please suggest.
    Thank you.

  • EssKayKay August 4, 2019, 8:27 pm

    I am looking for a command line routine or something that I can run from a batch file that opens a minimized app.

    I have the powershell routine that minimizes all my open apps which works great. I have another powershell routine that opens all the minimized apps. For the most part this works fine. However, periodically I want to open/activate just one of the minimized apps not all of them. Is there a way to “undo” or maximize (doesn’t actually have to be maximized, just opened or activated) a specific minimized app?

    Code that Minimizes:
    powershell -command “& { $x = New-Object -ComObject Shell.Application; $x.minimizeall() }”

    Code that Opens:
    powershell -command “& { $x = New-Object -ComObject Shell.Application; $x.UndoMinimizeAll() }”

    Thanks,
    Steve K.