locked
Powershell - Login to website RRS feed

  • Question


  • i am trying to use the example script of invoke-webrequest to login to a local site 

    $r = Invoke-WebRequest "https://www.acesso.gov.pt/jsp/loginRedirectForm.jsp?partID=PFIN&path=main.jsp?body=/external/slelei/SLELEI/listaLeiloes.htm"
    $r.Forms[0].username = "MyName" 
    $r.Forms[0].password = "MyPassword" 
    Invoke-RestMethod "https://www.acesso.gov.pt/jsp/loginRedirectForm.jsp?partID=PFIN&path=main.jsp?body=/external/slelei/SLELEI/listaLeiloes.htm" -Body $r

    and keep getting this error. I can't get any info about this --" SO8859_1' is not a supported encoding name. " -- Error.

    Any tips ?

    Invoke-WebRequest : 'ISO8859_1' is not a supported encoding name.
    Parameter name: name
    At C:\Users\jlmendes\Dropbox\pai\read2.ps1:7 char:6
    + $r = Invoke-WebRequest "https://www.acesso.gov.pt/jsp/loginRedirectForm.jsp?part ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Invoke-WebRequest], ArgumentException
        + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

    Cannot index into a null array.
    At C:\Users\jlmendes\Dropbox\pai\read2.ps1:8 char:1
    + $r.Forms[0].username = "MyName"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : NullArray

    Cannot index into a null array.
    At C:\Users\jlmendes\Dropbox\pai\read2.ps1:9 char:1
    + $r.Forms[0].password = "MyPassword"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : NullArray

    Invoke-RestMethod : 'ISO8859_1' is not a supported encoding name.
    Parameter name: name
    At C:\Users\jlmendes\Dropbox\pai\read2.ps1:10 char:1
    + Invoke-RestMethod "https://www.acesso.gov.pt/jsp/loginRedirectForm.jsp?partID=PF ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Invoke-RestMethod], ArgumentException
        + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand


    • Edited by Mendes1975 Tuesday, December 15, 2015 3:08 PM typos and stuff
    • Moved by Bill_Stewart Wednesday, February 10, 2016 5:20 PM Abandoned
    Tuesday, December 15, 2015 3:07 PM

All replies

  • When inspecting the site, what is the content-type provided in the response headers?
    Thursday, December 31, 2015 4:01 PM