Solved

Powershell script to Launch IE.

Posted on 2013-12-18
5
1,851 Views
Last Modified: 2014-01-30
I have the following script set to launch on a 2012 RDS server for a certain user.

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")

Open in new window


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.
0
Comment
Question by:victordr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 69

Expert Comment

by:Qlemo
ID: 39727609
There are a lot of different ways to do that, and a trivial one is to build a wait loop, checking if IE (iexplore.exe) is still running, and if not, issue the logout command.
while (get-process -name iexplore*) { sleep 5 }

Open in new window

The wildcards prevents get-process from throwing an exception if no IE is found.
0
 

Author Comment

by:victordr
ID: 39727846
but if it is a terminal server session, would it pick up other iexplore process running from other sessions?
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39728049
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

Open in new window

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.
0
 

Author Comment

by:victordr
ID: 39738435
How would i add this into the script?
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39738776
You would put that after $ie.Navigate, being the last commands of the script.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
In this Micro Tutorial viewers will learn how to use Windows Server Backup to create full image of their system. Tutorial shows how to install Windows Server Backup Feature on Windows 2012R2 and how to configure scheduled Bare Metal Recovery backup.…
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question