How to run a script daily in sharepoint online management shell

AQUEEL SULEMAN 1 Reputation point

I have a working powershell script that i need to run daily in Sharepoint. How do i launch sharepoint online management shell and login without having to do it manually? want it to run it daily as a batch process.

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,171 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Niklas Nussbaum 181 Reputation points

    Hi there,

    you can achive that by using Azure Automation. This helped me a lot:

    Otherwhise you can just create a Windows Scheduler Task for it.
    Sign in automatically to SPO would require to give credentials within the Script which would not be the best way to go

    1 person found this answer helpful.
    0 comments No comments

  2. Echo Du_MSFT 17,086 Reputation points


    Please follow these steps:

    1.Write and run a PowerShell script. If the script can run successfully, please save it.
    Ps:The script can list the file information in the “Lib” Document library over 5 days.
    This is a test script.

    2.Schedule PowerShell Script using Task Scheduler
    a) Open Task scheduler >> select Task Scheduler Library >> click Create Task

    b) On the General tab, you can set scheduler name.

    c) On the Trigger tab and click New button. In the New Trigger dialog, you can set conditions.

    d) On the Actions tab and click New button to set task actions. Once configured, you can specify conditions to determine whether the task should run. The task will not run if any condition specified here is not true.

    e) On the Settings tab, you can set additional advanced settings to control the task execution
    f) You can Run by right-clicking task name to test this task.

    You could refer to this article How to Schedule PowerShell Script using Task Scheduler.

    Echo Du


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments