Advertisement
3my

ps1

3my
Jun 29th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. Created:  January 18, 2014
  3. Version:  2.0
  4. Description:  On login, launch Internet Explorer to a specified URL, and then open an executable file.
  5. Notes:  If the workstation is running Windows 7, login as the user, open "GPEDIT.MSC", and navigate to the following location.
  6.  
  7. User Configuration\Windows Settings\Scripts (Logon/Logoff)
  8.  
  9. Next, open "Logon" and go to the "PowerShell Scripts" tab.  Then, add this script to it.  However, first modify  
  10. the following variables.  You can edit it in a text editor or in the PowerShell ISE.
  11.  
  12. $Url
  13. $Username
  14. $Password
  15. $Executable
  16.  
  17. IMPORTANT:  Before running the script, open the web browser and go to the web site that will be specified in this  
  18. script and right click in the username field and select Inspect Element.  Locate the "Input Name" and then copy and  
  19. paste it in place of "UsernameElement" located at the end of this script (line 61).  Then, inspect the password field,  
  20. and copy and paste the "Input Name" in place of "PasswordElement" located at the end of this script (line 62).  Then,  
  21. right click on the submit button on the URL and locate the Input Name and then copy paste it in place of "SubmitElement"
  22. at the end of this script (line 63).
  23.  
  24. #>
  25.  
  26. # Edit this to be the URL or IP address of the site to launch on login
  27.  
  28. $Url = “www.microsoft.com”
  29.  
  30. # Edit this to be the username
  31.  
  32. $Username=”name@microsoft.com”
  33.  
  34. # Edit this to the corresponding password
  35.  
  36. $Password=”password”
  37.  
  38. # Edit this to be the path to the executable.  Include the executable file name as well.
  39.  
  40. $Executable = "c:\windows\system32\notepad.exe"
  41.  
  42. # Invoke Internet Explorer
  43.  
  44. $IE = New-Object -com internetexplorer.application;
  45. $IE.visible = $true;
  46. $IE.navigate($url);
  47.  
  48. # Wait a few seconds and then launch the executable.
  49.  
  50. while ($IE.Busy -eq $true)
  51.  
  52. {
  53.  
  54. Start-Sleep -Milliseconds 2000;
  55.  
  56. }
  57.  
  58. # The following UsernameElement, PasswordElement, and LoginElement need to be modified first.  See the notes at the top
  59. # of the script for more details.
  60.  
  61. $IE.Document.getElementById(“usernameInput”).value = $Username
  62. $IE.Document.getElementByID(“passwordInput”).value=$Password
  63. $IE.Document.getElementById(“loginButton”).Click()
  64.  
  65. while ($IE.Busy -eq $true)
  66.  
  67. {
  68.  
  69. Start-Sleep -Milliseconds 2000;
  70.  
  71. }
  72.  
  73. Invoke-Item $Executable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement