Reputation: 33998
I have the following powershell command that will run on users pc on a scheduled basis, based on a REST API Call to know if they havent submitted the timesheet.
It works fine, but I would like to put the IE window as the main window at that moment.
$msgBoxInput = [System.Windows.MessageBox]::Show('You havent submitted the timesheet. Please do it now','xyz is watching you','OK','Error')
$IE=new-object -com internetexplorer.application
$IE.navigate2("www.microsoft.com")
$IE.visible=$true
Is it doable with powershell? in an easy way
Upvotes: 1
Views: 1944
Reputation: 773
It should be doable. Have a look at this example:
## Find all Active Windows Titles
$windows=Get-Process | Where-Object {$_.MainWindowTitle -ne ""} | Select-Object MainWindowTitle
## Find Specific name
$WindowTitle=($windows | ? {$_ -match "Internet Explorer"} ).MainWindowTitle
## Add Type and Focus Activate the Window
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate($WindowTitle)
You just have to make sure that you have the correct MainWindowTitle.
Hope it helps
Upvotes: 1