web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Replicate Powershell w...
Power Automate
Unanswered

Replicate Powershell with Power Automate

(1) ShareShare
ReportReport
Posted on by

I have a daily task to download the same set of PDF documents from a website and put them on my company SharePoint. Due to IT restrictions the way I have "automated" this using PowerShell is clunky and not ideal as it has to run from my computer, not in the cloud.

The script is below. I cannot maintain an authenticated "web session" in PowerAutomate or extract one-time link to the digital library the files come from. 

 

 

#Set the log-in parameters 
$postParams = @{action='/log-in';username='myusername';password='*******'}

#Log into website at Log-In page and set-up a web session so authentication carries over
Invoke-WebRequest -Uri 'https://www.website/log-in' -Method Post -Body $postParams -SessionVariable NNN

#Extract the one-time digital library link from my-profile page and access the digital library to authenticate the web session
$DigiLibLink = (Invoke-WebRequest -Uri 'https://www.website/my-profile' -WebSession $NNN).Links | Where-Object href -like 'https://digital-libraryURL*' | select -expand href
Invoke-WebRequest -Uri $DigiLibLink -WebSession NNN

#Download the Files using their direct links and the authenticated websession
Invoke-WebRequest 'https://digital-libraryURL/DownloadPDF?nodeid=xxxx' -WebSession $NNN -OutFile 'C:\OneDriveFolder\File1.pdf'
Invoke-WebRequest 'https://digital-libraryURL/DownloadPDF?nodeid=xxxx' -WebSession $NNN -OutFile 'C:\OneDriveFolder\File2.pdf'

 

 

Could someone advise how I could achieve these steps, please?

Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 474

#2
11manish Profile Picture

11manish 268

#3
David_MA Profile Picture

David_MA 243 Super User 2026 Season 1

Last 30 days Overall leaderboard