none
Powershell - Downloading file from website RRS feed

  • Question

  • Hi Experts,

    I am trying to download file from the SharePoint portal.

    I was able to login successfully and open the file , but unable to download the file. Could you please advise. Thanks.

    $username="username"
    $password="password"
    $url = "https://mycompany.com/sites/folder/document.xlsx"
    $destination  = "c:\temp\document.xlsx"
    
    $ie = New-Object -ComObject InternetExplorer.Application
    $ie.Visible = $true
    $ie.navigate($url)
    
    Start-Sleep -Milliseconds 10000
    while($ie.Busy){Sleep 1} 
    
    $ie.Document.getElementByID("Ecom_User_ID").value = $username
    $ie.Document.getElementByID("Ecom_Password").value = $password
    
    Invoke-WebRequest -Uri $url -Outfile $destination
    $obj = new-object -com WScript.Shell
    $obj.AppActivate('Internet Explorer')
    $obj.SendKeys('s')
    $obj.SendKeys('{Enter}')
    

    • Moved by Bill_Stewart Monday, July 29, 2019 8:08 PM Off-topic
    Monday, March 4, 2019 10:28 PM

All replies