victordr
asked on
Powershell script to Launch IE.
I have the following script set to launch on a 2012 RDS server for a certain user.
I would like to know if it possible to have it so if the end-users closes the IE Window, it will log them off?
I have them connecting from a thin client so that would just automatically log back into the RDS server.
Function maxIE
{
param($ie)
$asm = [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$screen = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
$ie.Width = $screen.width
$ie.Height =$screen.height
$ie.Top = 0
$ie.Left = 0
$ie.fullscreen = $true
}
cls
$ie = new-object -com "InternetExplorer.Application"
$ie.visible = $true
maxIE $ie
while ($ie.busy) {sleep -milliseconds 50}
$ie.navigate("https://share.domain.com/sites/PRD/Lists/In%20Transfer%20Sheet/AllItems.aspx")
I would like to know if it possible to have it so if the end-users closes the IE Window, it will log them off?
I have them connecting from a thin client so that would just automatically log back into the RDS server.
ASKER
but if it is a terminal server session, would it pick up other iexplore process running from other sessions?
Absolutely true, at least if the user is able to see all processes. Let's forget that approach, and instead use the Internet.Application object you already created:
while ($ie.HWnd) { sleep 5 }
logoff
is much better. As soon as that specific IE is closed, the loop will stop, and log the user off, which terminates the RDS session.
ASKER
How would i add this into the script?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
The wildcards prevents get-process from throwing an exception if no IE is found.