Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
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?

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492