hi jaynarayan,
Step 1: Create a .ps1 file
To run a .ps1 script from the task scheduler, you must pass it as a parameter to powershell.exe.
- Run Notepad.
- Type or paste the following script into a blank document:
- Windows PowerShell
- Backup-SPSite
Backup-SPSite -Identity <SPSitePipeBind> -Path <String> [-AssignmentCollection<SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-NoSiteLock <SwitchParameter>] [-UseSqlSnapshot <SwitchParameter>] [-WhatIf [<SwitchParameter>]][<CommonParameters>]
- Save the file as AutoBackup.ps1. Be sure to select All Files under Save as type.
- By default, the file should be saved in your user profile folder (for example, C:\Users\myLogon\AutoBackup.ps1).
- To verify that the script works:
- Run an elevated PowerShell window.
- Type the location of the script. For example: C:\Users\myLogon\AutoBackup.ps1
Step 2: Create a task in Windows Task Scheduler
The following procedure describes how to create a task on the head node that runs the AutoBackup.ps1 script every day at 6:00 AM.
To create a task in Windows Task Scheduler that runs AutoBackup.ps1 every day
- Log on to the head node as a user with administrative permission.
- Click Start, point to Administrative Tools, then click Task Scheduler.
- If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
- In Task Scheduler, in Actions, click Create Task. The Create Task dialog box appears.
- In the General tab:
- In Name, type: AutoBackup
- Select the Run whether user is logged on or not radio button.
- Select the Run with highest privileges check box.
- In the Trigger tab:
- Click New. The New Trigger dialog box appears.
- Select the Daily radio button.
- Set the start time to 6:00 AM.
- Click OK.
- In the Actions tab:
- Click New. The New Action dialog box appears.
- In Settings, in Program/Script, type:
- powershell.exe
- In Add arguments, type the following, where C:\Users\myLogon\AutoBackup.ps1 is the location of the script that you want to run:
- -command “C:\Users\myLogon\AutoBackup.ps1”
- Click OK.
- In the Create Task dialog box, click OK. When prompted, enter your password.
- Verify that the new task works:
- In Task Scheduler, in the navigation pane, select Task Scheduler Library.
- In the view pane, right-click AutoBackup, then click Run.
I hope u got all the steps required...
cheerssss...:)