Troubleshooting PowerShell Based Scheduled Tasks

If you want to schedule any task using Task scheduler in the Windows system, we need to make sure that all the configuration has been setup properly.

If we are running backup tasks for SharePoint content database with PowerShell scripts, we need to make sure that the script is correct and has passed all parameters successfully. Also, we should have appropriate permissions to run backup on SharePoint Server. We need to see the path also, which you have assigned in order to ensure whether it exists or not.

Once everything given above is done, create a simple task in task scheduler and attach the PS1 file and save the same.

Now, we need to run this and later we will receive an error called Backup –SPFarm: A positional parameter cannot be found that accepts an argument. See the screenshot given below.

  • After troubleshooting, I learned that we have not passed PowerShell add arguments in task scheduler.

  • To fix this above issue, just open task schedule and open the properties of task, which is configured in task scheduler.

  • Selected Action tab from task properties, edit the same task and add PowerShell argument in the starting file of the selected path.

Once everything is done, save the same and rerun again. Now, we will we get an expected result without any issue.

Ebook Download
View all
Learn
View all