I am writing a script to check if a program is running or not. If it's not running, then open it. If it's already running, then maximize the program's window or prompt it so the user can notice it.
How do I maximize an existing process' main window?
$notepad= Get-Process Notepad -ErrorAction SilentlyContinue
if ($notepad) {
$notepad | #maximize notepad if it's already opened
}
else {
notepad
}