Skip to main content

Notifications

Community site session details

Community site session details

Session Id : fAEPZObxdsyLjboTEO3/n4
Power Automate - Building Flows
Unanswered

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

Like (0) ShareShare
ReportReport
Posted on 8 Apr 2024 13:55:00 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?

  • MarkRahn Profile Picture
    984 Super User 2025 Season 1 on 09 Apr 2024 at 17:42:22
    Re: Using Power Automate to run PowerShell Script, no conditions needed, just needs to run 1 time daily at midnight

    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

  • SPS-DEV-22 Profile Picture
    516 on 08 Apr 2024 at 17:07:49
    Re: Using Power Automate to run PowerShell Script, no conditions needed, just needs to run 1 time daily at midnight

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

  • MarkRahn Profile Picture
    984 Super User 2025 Season 1 on 08 Apr 2024 at 16:39:03
    Re: Using Power Automate to run PowerShell Script, no conditions needed, just needs to run 1 time daily at midnight

    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 08 Apr 2024 at 16:04:03
    Re: Using Power Automate to run PowerShell Script, no conditions needed, just needs to run 1 time daily at midnight

    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
    984 Super User 2025 Season 1 on 08 Apr 2024 at 15:23:45
    Re: Using Power Automate to run PowerShell Script, no conditions needed, just needs to run 1 time daily at midnight

    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 08 Apr 2024 at 15:03:34
    Re: Using Power Automate to run PowerShell Script, no conditions needed, just needs to run 1 time daily at midnight

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

  • MarkRahn Profile Picture
    984 Super User 2025 Season 1 on 08 Apr 2024 at 14:57:35
    Re: Using Power Automate to run PowerShell Script, no conditions needed, just needs to run 1 time daily at midnight

    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 08 Apr 2024 at 14:21:11
    Re: Using Power Automate to run PowerShell Script, no conditions needed, just needs to run 1 time daily at midnight

    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
    984 Super User 2025 Season 1 on 08 Apr 2024 at 14:15:41
    Re: Using Power Automate to run PowerShell Script, no conditions needed, just needs to run 1 time daily at midnight

    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

     

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,776 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,093 Most Valuable Professional

Leaderboard
Loading started