title: How do you get table data from a website after you login using powershell?
body: <p>My company wants me to grab data from their internal website, organize it, and send it to a database. The data is displayed on tables that you navigate to within the site. I'm wanting to pull the fields into a file or memory for further processing.</p>
  
  <p>So far, I can log into the site in powershell by getting the submit login button's ID, and passing my username/password. I'm able to pass use the navigate method to change the page to the appropriate page within the site. However, running an Invoke-WebRequest on the new page, as well as using the Net.WebClient on the new page is returning the information found on the original site's login screen(I know, because nothing from the table makes it into the returned values, regardless of the commands I use). The commented code is what I've tried previously. </p>
  
  <p>Here is the code-minus the values of my id/password/site link </p>
  
  <pre><code>[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  $ie = New-Object -ComObject 'internetExplorer.Application'
  $ie.Visible= $true # Make it visible
  $username="myid"
  $password="mypw"
  $ie.Navigate("https://webpage.com/index.jsp")
  While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
  $usernamefield = $ie.document.getElementByID('login')
  $usernamefield.value = "$username"
  $passwordfield = $ie.document.getElementByID('password')
  $passwordfield.value = "$password"
  $Link = $ie.document.getElementByID('SubmitLogin')
  $Link.click()
  $url = "https://webpage.com/home.pa#%5BT1%2CM181%5D"
  $ie.Navigate($url) 
  While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
  $doc = $ie.document
  $web = New-Object Net.WebClient
  $web.DownloadString($url)
  #$r = Invoke-WebRequest $url
  #$r.Forms.fields | get-member
  #$InnerText = $r.AllElements | 
  #    Where-Object {$_.tagName -ne "TD" -and $_.innerText -ne $null} | 
  #    Select -ExpandProperty innerText
  #write-host $InnerText
  #$r.AllElements|Where-Object {$_.InnerHtml -like "*=*"} 
  
  #$doc = $ie.Document
  #$doc.getElementByID("ext-element-7") | % {
  #    if ($_.id -ne $null){
  #        write-host $_.id
  #    }
  #}
  $ie.Quit()
  </code></pre>