Skip to content

Instantly share code, notes, and snippets.

@cdiaz
Last active April 30, 2017 01:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cdiaz/976e0de8f93d58902969a9302474be93 to your computer and use it in GitHub Desktop.
Save cdiaz/976e0de8f93d58902969a9302474be93 to your computer and use it in GitHub Desktop.
Automation script to login into Chairá Platform from PowerShell

##Instructions:

####Download and Install Chocolatey (Package Manager for PowerShell) Run in the Command Line (cmd)

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

#####Other installation methods: https://github.com/chocolatey/choco/wiki/Installation

####Make sure the chocolatey is include in $env:Path

$env:path

####Check installed version

choco

###Install Wasp (Windows Automation Snap-in for Powershell)

choco install wasp

####More info https://chocolatey.org/packages/wasp

####Copy the following modules to Windows PowerShell Module Path

copy-item C:\ProgramData\chocolatey\lib\wasp -Recurse -Destination C:\Windows\system32\WindowsPowerShell\v1.0\Modules
copy-item C:\ProgramData\chocolatey\lib\autoload -Recurse -Destination C:\Windows\system32\WindowsPowerShell\v1.0\Modules
copy-item C:\ProgramData\chocolatey\lib\reflection -Recurse -Destination C:\Windows\system32\WindowsPowerShell\v1.0\Modules

Usage

Save this Script and running from the Command Line (cmd)

@powershell -ExecutionPolicy unrestricted ./loginchaira.ps1 'username' 'password'
Import-Module wasp # Windows Automation Snap-in for Powershell
$url = 'https://chaira.udla.edu.co/Chaira/Logon.aspx'
$username = $args[0]
$password = $args[1]
$ie = New-Object -COM InternetExplorer.Application -Property @{
Visible = $true
Navigate = $url
}
while($ie.busy) {
#Focus window iexplore
$window = Select-UIElement -ProcessName iexplore
#Close Chaira Alert
$window | Send-UIKeys '{ESCAPE}'
}
$ie.Document.getElementById("_Usuario").value = $username
$ie.Document.getElementById("_Password").value = $password
$ie.Document.getElementByID("ext-gen49").Click()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment