Downloading (Exporting) Information form Vendor Web Consoles

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Russ12345 Russ12345 10 months, 3 weeks ago.

  • Author
  • #32498
    Profile photo of Russ12345

    I am having really difficult time doing this and hoping that someone already did something similar and can get me through this "wall" in front of me.

    I have various consoles that I am working with and my goal is to schedule a task that Exports reports from these vendors and send them in an email or save them to the drive.

    The vendor web consoles I am working with are Trend Micro and Bit9.

    In both cases, I am not able to authenticate using invoke-webrequest (unless I am authenticated and just can't tell)

    The only way so far, was to use InternetExplorer.Application. This way, I am able to navigate all the way to the "Export" button, but it pulls up a dialog to Save/Save As and requires manual intervention and IE must be visible (this defeats my scheduled task requirement)

    Below is my code for IE

    $URI = "https://SERVER:4343/officescan/console/html/cgi/cgiChkMasterPwd.exe"
    $ie = new-object -com InternetExplorer.Application
    $ie.Visible = $true
    do {sleep 1} until (-not ($ie.Busy))
    $doc = $ie.document
    If ($doc.getelementsbytagname('a') | ? {$_.href -like $URI}) {
    $link = $doc.getelementsbytagname('a') | ? {$_.href -like $URI}
    do {sleep 1} until (-not ($ie.Busy))

    $UserName = $doc.getElementById('UserName')
    $Password = $doc.getElementById('T122')
    $Submit = $doc.getElementById('button22')

    $UserName.value = 'UserName'
    $Password.value = 'Password'
    do {sleep 1} until (-not ($ie.Busy))

    do {sleep 1} until (-not ($ie.Busy))

    My code using Invoke-WebRequest

    add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
    ServicePoint srvPoint, X509Certificate certificate,
    WebRequest request, int certificateProblem) {
    return true;
    [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

    #$creds = Get-Credential
    $URI = 'https://ServerHostName:4343/officescan/console/html/cgi/cgiChkMasterPwd.exe'
    $website = Invoke-WebRequest -URi $URI -SessionVariable Trend
    $form.fields.UserName = 'UserName'
    $form.fields.T122 = 'Password'
    $page=Invoke-WebRequest -Uri 'https://ServerHostName:4343/officescan/console/html/cgi/cgiShowClientAdm.exe?id=1000$' -WebSession $Trend -Method POST -Body $form.Fields

  • #32510
    Profile photo of Dave Wyatt
    Dave Wyatt

    That sort of browser automation can be a real pain in the butt. If your app doesn't offer a web API that is friendly to Invoke-WebRequest or Invoke-RestMethod (which in this case, it doesn't seem to; you shouldn't have to be monkeying around with forms or javascript stuff), then you might have better luck by looking into Selenium ( It should hopefully give you less of a headache than trying to use the InternetExplorer COM object.

  • #32538
    Profile photo of Russ12345

    Thank you Dave,

    it looks to me that with SeleriumHQ I would be forced to have the browser window open and therefore I cant have these exports run in the background...

    Unless there is something I've missed...

You must be logged in to reply to this topic.