'Need to minimize a particular window

I had tried with below script. While using the below command it will minimize all opened applications. I need minimize only the policy updating window only(Gpupdate.exe). please find the attached gpupdate windows screenshots.GPUPDATE (Policy updating windows i need to minimize

Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList "gpupdate.exe"

            Start-Sleep -s 1
            $shell = New-Object -ComObject "Shell.Application"
            $shell.minimizeall() 


Solution 1:[1]

When using Windows 11 (and the Windows Terminal), this script may not work properly with using $PID. To minimize the Windows Terminal, use

(Get-Process | Where-Object {$_.name -Match 'Terminal'}) | Set-WindowState -State MINIMIZE

The problem is, that it minimizes all Windows Terminal windows.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1