How to code it using Powershell Script?

This topic contains 1 reply, has 2 voices, and was last updated by  postanote 4 weeks ago.

  • Author
    Posts
  • #91853

    oemPower
    Participant

    I would like to know on how to login using PowerShell, and what wrong is following coding?

    Does anyone have any suggestions?
    Thanks in advance for any suggestions

    HTML Coding
    #

    #
    #
    #E-Mail *
    #
    #Password *

    #
    #

    PowerShell Script
    $clnt = new-object System.Net.WebClient
    $URL = "https://www.sample.com/login/"
    $token = "aaabbbcccjfheh48u8jdjd"
    $username = "sample_username"
    $password = "sample_password"
    $postParams = @{FORM_TOKEN=$token; LoginForm_email=$username; LoginForm_password=$password}
    Invoke-WebRequest -URi $URL -Method POST -body $postParams

  • #91907

    postanote
    Participant

    What you are doing and asking about is s very common thing. You just have to make sure you are calling the objects of the fomr correctly.

    There are lots of examples of how to do this all over the web.

    For example:
    'geekeefy.wordpress.com/2015/06/07/powershell-automated-login-to-all-your-websites-in-one-go'

    There are direct examples in the PoSH built-in help files ...

        
        # Get parameters, examples, full and Online help for a cmdlet or function
        (Get-Command -Name Invoke-WebRequest).Parameters
        Get-help -Name Invoke-WebRequest -Examples
        Get-help -Name Invoke-WebRequest -Full
        Get-help -Name Invoke-WebRequest -Online
    

    ... and sample scripts provide via the MS PowerShellGallery.com and the Scripting Guys blog.

    Automate login to website
    A script to log in to a website, parse the contents into objects, click some buttons and tick some checkboxes.
    'gallery.technet.microsoft.com/scriptcenter/9d66f3bd-a051-4b0f-833c-868de0f0b653'

You must be logged in to reply to this topic.