Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # If there are existing Internet Explorer processes, close it
- $IE_Process = Get-Process iexplore -ErrorAction Ignore
- if ($IE_Process) {
- $IE_Close = Foreach-Object { $IE_Process.CloseMainWindow() }
- }
- Stop-Process -Name "iexplore" -ErrorAction Ignore
- # Login Information
- $url = "http://xxx.xxx.xxx.xxx/"
- $username = "xxxxxxxx"
- $password = "xxxxxxxx"
- # Open an IE process
- $ie = New-Object -com internetexplorer.application;
- $ie.silent = $true
- $ie.navigate($url);
- while ($ie.Busy -eq $true)
- {
- Start-Sleep -s 1;
- }
- # The stupid webpage needs to submit twice
- $ie.Document.getElementById("loginname").value = $username
- $ie.Document.getElementByID("password").value = $password
- $ie.Document.getElementById("button").Click()
- Start-Sleep -s 1;
- $ie.Document.getElementById("loginname").value = $username
- $ie.Document.getElementByID("password").value = $password
- $ie.Document.getElementById("button").Click()
- # Close the IE process
- $IE_Process = Get-Process iexplore -ErrorAction Ignore
- if ($IE_Process) {
- $IE_Close = Foreach-Object { $IE_Process.CloseMainWindow() }
- }
- Stop-Process -Name "iexplore" -ErrorAction Ignore
- Remove-Variable -Name ie,username,password,url,IE_Process -ErrorAction Ignore
- C:WINDOWSsystem32WindowsPowerShellv1.0powershell.exe -ExecutionPolicy RemoteSigned -File C:UsersMyNameDocumentsPowershelllogin_IE.ps1
- C:WINDOWSsystem32WindowsPowerShellv1.0powershell.exe
- -ExecutionPolicy Unrestricted -File C:UsersMyNameDocumentsPowershelllogin_IE.ps1
Add Comment
Please, Sign In to add comment