PoshCode Archive  Artifact [8de797dddd]

Artifact 8de797dddd233b4264628505a43f350d2f66c1390ce371597ab3c32af0b694d1:

  • File Open-Webmin.ps1 — part of check-in [1f86fa0f4a] at 2018-06-10 14:02:28 on branch trunk — Allows you to open a Webmin interface in IE from the command line, automatically skipping an SSL error and logging in with the provided username and password. I use this script as an external tool in mRemoteNG with the following powershell arguments line: “-NoProfile -ExecutionPolicy RemoteSigned -WindowStyle Hidden -File “C:\Users\kim.shepherd\Scripts\Webmin-Login.ps1” -Username Username -Password Password -URL https://%Hostname%:10000” (user: Kim Shepherd size: 1599)

# encoding: ascii
# api: powershell
# title: Open Webmin
# description: Allows you to open a Webmin interface in IE from the command line, automatically skipping an SSL error and logging in with the provided username and password.  I use this script as an external tool in mRemoteNG with the following powershell arguments line: “-NoProfile -ExecutionPolicy RemoteSigned -WindowStyle Hidden -File “C:\Users\kim.shepherd\Scripts\Webmin-Login.ps1” -Username Username -Password Password -URL https://%Hostname%:10000”
# version: 0.1
# author: Kim Shepherd
# license: CC0
# x-poshcode-id: 5840
# x-archived: 2015-05-02T13:23:58
# x-published: 2015-05-01T15:35:00
#
#

Param(  
    [string]$Username,
    [string]$Password,
    [String]$URL
)

# Create a new IE instance
$ie = New-Object -com internetexplorer.application 
$ie.visible = $true

$ie.navigate($URL)

#wait for the page to load
while ($ie.ReadyState -ne 4)
{
    Start-Sleep -Seconds 1;
}

# If there is an SSL error, click past it.
if ($ie.document.url.contains("SSLError"))
{
    ($ie.Document.getElementsByTagName("a") | where { $_.innerText.toLower().Contains("continue to this website") } | select -first 1).click()

    Start-Sleep -Seconds 1;

    while ($ie.ReadyState -ne 4)
    {
        Start-Sleep -Seconds 1
    }
}

# Enter the username and password and click the 'login' button
$ie.Document.getElementById("user").value = $Username
$ie.Document.getElementByID("pass").value = $Password
($ie.Document.getElementsByTagName("input") | where {$_.Value -eq "Login"}).click()