How to run a script daily in sharepoint online management shell

AQUEEL SULEMAN 1 Reputation point
2020-09-22T23:53:41.26+00:00

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.

SharePoint
SharePoint
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
    2020-09-23T07:59:23.447+00:00

    Hi there,

    you can achive that by using Azure Automation. This helped me a lot: https://practical365.com/sharepoint-online/how-to-use-azure-automation-with-sharepoint-online-part-one/

    Otherwhise you can just create a Windows Scheduler Task for it. https://www.windowscentral.com/how-create-automated-task-using-task-scheduler-windows-10
    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
    2020-09-23T07:52:53.807+00:00

    @AQUEEL SULEMAN

    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
    26842-task1.png

    b) On the General tab, you can set scheduler name.
    26861-task2.png

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

    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.
    26871-task4.png

    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.
    26686-task5.png

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

    Thanks,
    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