Want to download web url content

Welcome Forums General PowerShell Q&A Want to download web url content

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
6 months, 4 weeks ago.

  • Author
    Posts
  • #101001

    Participant
    Points: 0
    Rank: Member

    Hi All,

    I have one url and I want to download the all web url content and copy it to some text file but unable to do so. That URL have username and password as well so please guide how to do this. Do I need to pass credentials also in script. If yes, then how. Any insight would be appreciated.

    Till now code is –

    Invoke-WebRequest -Uri abc.com/#/queues -Credential "guest"
    $WebClient = New-Object System.Net.WebClient
    $WebClient.DownloadFile('abc.com/#/queues/%2F/onp.document.dlq','C:\Users\ankitpar\test.txt')

    but on executed it's not giving the desired result. It's not copying the web page.

    Thanks
    Ankit

  • #101013

    Participant
    Points: 297
    Helping Hand
    Rank: Contributor

    A brief illustration:

    $Cred = Get-Credential
    $Webclient.Credentials = $Cred
    $Webclient.DownloadFile($Url,$Destination)

    Personally I find this stuff a bit easier with the built in Invoke-WebRequest cmdlet, but either works, really. 🙂

    • #101041

      Participant
      Points: 0
      Rank: Member

      Hi Joel,

      Thanks for replying but I have already tried this via google but didn't get the actual result. The issue is on web url there is a tab of "get-message" and after clicking on that tab the result will show. In my case i think i have to call the "get-message" tab in script and after that only then the result will come so do you have any idea that how to do this?

      Thanks in advance
      Ankit

The topic ‘Want to download web url content’ is closed to new replies.