Showing posts with label form. Show all posts
Showing posts with label form. Show all posts

Monday, August 27, 2007

How to convert C# forms to PowerShell

 

Check out this post from Doug's blog. Among some other PowerShell posts Doug explains how to convert a simple C# forms into PowerShell script.

Monday, January 29, 2007

Automated Web forms


The listed function will Auto Login into Gmail. You can include it in the your Profile for fast execution. BTW, setting the value of a text input in PowerShell doesn’t follow the VBScript syntax, and so :

$ie.document.FormName.InputName.value = "something" will raise an error: Property 'value' cannot be found on this object; make sure it exists and is settable. At line:1 char:18 + $ie.theForm.TheInputName.v <<<< alue="something"

The code also implements the Get-Credential cmdlet. You can prompt the user to enter his credentials in a relative "secure" way (10x to /\/\o\/\/ ThePowerShellGuy for his help).

function Login-GMail{
    param(
        [string]$uname,
        [string]$url="http://www.gmail.com",
        [bool]$cookie=$false
    )

    $creds = get-credential $uname
    $pass = $creds.GetNetworkCredential().Password
    $ie=new-object -com internetexplorer.application
    $ie.visible=$true $ie.navigate($url)
    while($ie.ReadyState -ne 4) {start-sleep -m 100}     
    $ie.document.getElementById("Email").value=$uname     
    $ie.document.getElementById("Passwd").value = $pass     
    $ie.document.getElementsByName("PersistentCookie") | foreach {$_.checked=$cookie}     
    $ie.document.getElementById("gaia_loginform").submit()
}
Set-Alias gmail Login-Gmail

To activate it just type: gmail yourAccountName

$hay