Notifications
Announcements
I wrote a PowerShell script, it runs fine from the desktop, what I want to do is add the code to a Power Automate to have it run every day at midnight...
How would I do this and does it require the Premium License?
are there any examples to do this?
Hi @SPS-DEV-22
Here is an article on what you are asking to do but it requires a Premium License to execute Azure Automation.
How to run PowerShell scripts to automate manual processes in Office 365 | Practical365
To go this route, you need access to Azure to create the runbook so you might as well just let Azure handle the schedule as well. This way you avoid the need for a Premium License for Power Automate.
Tutorial - Create a PowerShell Workflow runbook in Azure Automation | Microsoft Learn
And a walkthrough is here also:
Schedule PowerShell Scripts Using Azure Automation (m365scripts.com)
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up.
Thanks
-Mark
quick question, I'm not touching AZURE with the script. It is just a move documents every day at midnight, We do not have the Premium license .
If you went will a Runbook in Azure, that gets you the ability to run a PowerShell script.
You said that your PowerShell script "just moves documents". What is the source and destination? Are you moving files between SharePoint document libraries? SharePoint has a "Move file" Action. Are you moving files between network drives? Based on what your PowerShell script does, you may want to consider re-writing it as a flow. It all depends on where your documents live as to if you could write a flow to replace your PowerShell.
If you truly need to execute your PowerShell script and it is accessing local drives, then you may want to consider automating running the script using "Windows Task Scheduler".
It moves files PDF from a Shared Drive to a SharePoint Document library. Nothing too big.
I know this is getting away from your original request of running a PowerShell script, but if you consider replacing your PowerShell with a Flow that does the same actions then you could take a look at this YouTube video:
Power Automate - Get Files from Shared/Network Drive to SharePoint/OneDrive (youtube.com)
This video shows how to take a file from a Network Share to a SharePoint Document library. You would need to create a data gateway.
I tried that item, however the gateway needed, presented the biggest issue. and I only want the PDF files, not all the other files stored on the network shared.
I cannot find the File System, and the other items otherwise I would do it and if it doesn't require premium.
I would continue to use Windows Task Scheduler to run your PowerShell.
If you have an absolute requirement to make a Power Automate flow to move/copy your files from a Network Share to a SharePoint Library, then you can try using the "File System" Actions.
If you are not seeing these, then your Power Automate admin may have put some sort of Governance in place. For any sort of solution, you are going to have to provide an Identity (User information) that has permission to access the Shared Drive. Even running a PowerShell scripts requires you to provide User Identity of some sort.
I'm going to go with the PowerShell, I did want to get the automation, but the PowerShell works
Could you mark one of the answers as a Solution to your question? Or provide a Kudo as it encourages users to answer questions?
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.
In our never-ending quest to improve we are simplifying the forum hierarchy…
We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Michael E. Gernaey 538 Super User 2025 Season 2
Tomac 405 Moderator
abm abm 252 Most Valuable Professional