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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Using Power Automate t...
Power Automate
Unanswered

Using Power Automate to run PowerShell Script, no conditions needed, just needs to run 1 time daily at midnight

(0) ShareShare
ReportReport
Posted on by 516

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?

Categories:
I have the same question (0)
  • MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    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

     

     

  • SPS-DEV-22 Profile Picture
    516 on at

    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 .

     

  • MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    Hi  @SPS-DEV-22

     

    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".

     

    -Mark

    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.

     

  • SPS-DEV-22 Profile Picture
    516 on at

    It moves files PDF from a Shared Drive to a SharePoint Document library. Nothing too big.

  • MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    Hi @SPS-DEV-22 

     

    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.

     

    -Mark

  • SPS-DEV-22 Profile Picture
    516 on at

    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.

  • MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    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.

    MarkBandR_0-1712593932223.png

    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.

     

    -Mark

     

     

  • SPS-DEV-22 Profile Picture
    516 on at

    I'm going to go with the PowerShell, I did want to get the automation, but the PowerShell works

  • MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    Hi @SPS-DEV-22 

     

    Could you mark one of the answers as a Solution to your question? Or provide a Kudo as it encourages users to answer questions?

     

    Thanks

    -Mark

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard