How to Create a PowerShell Scheduled Task with Error SecurityError PSSecurityException FullyQualifiedErrorId

Use Task Scheduler to Run a PowerShell Script

The first option that we are going to look at is using the task scheduler in Windows to run a PowerShell Script. The Windows Task Scheduler originates from Windows 95! and is a great way to schedule tasks in Windows.

o run PowerShell scripts with the task scheduler, we can’t simply select the PowerShell file that we want to schedule. What we are going to do is run the “program” PowerShell and use the arguments to select the file that we want to run.

  1. Open Task SchedulerClick on Start and type “Task scheduler” to open it. Or select it in the Start Menu under Windows Administrative Tools (or Windows Tools when using Win 11)
  2. Create a new basic taskClick on Create Basic Tasks… in the action bar on the right side and give your task a name.
    (I recommend organizing your tasks in folders, create them on the left side first)

3. Schedule the taskThe trigger determines when the task should be executed. Choose a trigger, for example, Weekly, and click Next to configure when exactly the tasks need to be executed.

4. Set the ActionHere comes the important part, for the action, we are going to Start a Program

5. Start a Program – PowerShellThe program that we want to run is PowerShell. Just enter PowerShell in the Program/Script field (see screenshot in step 6), you don’t need to find the exact path to the executable.

6. Add ArgumentsIn the arguments field, we are going to add the argument -File and path to the PowerShell script. It’s also a good idea to add the PowerShell switch -NoProfile and set the -ExecutionPolicy to ByPass.

If your scripts require any parameters then you can add them after the path (for example the -Output parameter):

-NoProfile -ExecutionPolicy Bypass -File “C:\scripts\ADHealth.ps1” -Output “HTML”

7. Start inAlways set the Start in location to the same path as where your script is located. This way any exports that your script generates will be stored in the same location as your script. Otherwise, the output will be saved in C:\Windows\System32

8. FinishClick on Next and review your settings on the finish screen. Make sure that you select Open the properties dialog … so we configure some more settings.

9. Advanced Settings

There are two settings that we need to change for our scheduled PowerShell task. We will need to make sure that the script runs even when we are not logged on, which you do on the General tab.

And we want to make sure that the script stops if it’s running for more than a day. Change this setting under Settings and set Stop the task if it runs longer than to 1 day or less.

10. Save the taskClick Ok and enter your password, so the task can run when you are not logged on. It is always a good idea to test your task, right-click on it, and choose Run to run the task now.

Fix for PowerShell Script cannot be loaded because running scripts is disabled on this system error

On trying to run a PowerShell script from the PowerShell console, I received this error message: “File C:\temp\GenerateRpt.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1 CategoryInfo: SecurityError PSSecurityException FullyQualifiedErrorId : UnauthorizedAccess”

Set the Execution Policy

Set the execution Policy with the following command:

Set-ExecutionPolicy RemoteSigned

You’ll see a security risk warning. Type “Y” or “A” when prompted to proceed. That’s all! This should solve the issue.


15 thoughts on “How to Create a PowerShell Scheduled Task with Error SecurityError PSSecurityException FullyQualifiedErrorId

  1. Its like you read my mind You appear to know a lot about this like you wrote the book in it or something I think that you could do with some pics to drive the message home a little bit but instead of that this is fantastic blog An excellent read I will certainly be back

  2. I have been surfing online more than 3 hours today yet I never found any interesting article like yours It is pretty worth enough for me In my opinion if all web owners and bloggers made good content as you did the web will be much more useful than ever before

  3. I loved as much as youll receive carried out right here The sketch is tasteful your authored material stylish nonetheless you command get bought an nervousness over that you wish be delivering the following unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this hike

  4. I have been browsing online more than three hours today yet I never found any interesting article like yours It is pretty worth enough for me In my view if all website owners and bloggers made good content as you did the internet will be a lot more useful than ever before

  5. I do trust all the ideas youve presented in your post They are really convincing and will definitely work Nonetheless the posts are too short for newbies May just you please lengthen them a bit from next time Thank you for the post

  6. My brother recommended I might like this web site He was totally right This post actually made my day You cannt imagine just how much time I had spent for this information Thanks

  7. I do not even know how I ended up here but I thought this post was great I dont know who you are but definitely youre going to a famous blogger if you arent already Cheers

  8. Ive read several just right stuff here Certainly price bookmarking for revisiting I wonder how a lot effort you place to create this kind of great informative website

  9. Hi i think that i saw you visited my web site thus i came to Return the favore I am attempting to find things to improve my web siteI suppose its ok to use some of your ideas

  10. certainly like your website but you need to take a look at the spelling on quite a few of your posts Many of them are rife with spelling problems and I find it very troublesome to inform the reality nevertheless I will definitely come back again

Leave a Reply

Your email address will not be published. Required fields are marked *

RELATED POST

Delete All Files Older than x Days using PowerShell

How to Delete Older Files Using PowerShell? Deleting unnecessary files is important for keeping your computer and storage running smoothly.…

Managing IIS Log File Storage Windows Server 2012-2016-2019

Overview The log files that IIS generates can, over time, consume a large amount of disk space. Logs can potentially…

Outlook keeps displaying error: Contact the server for information

What version of Outlook are you using? See What version of Outlook do I have? (microsoft.com). What were you trying…

Raising the forest functional level to Windows Server 2016

Just like the Active Directory DFL, the FFL also determines the availability of new Active Directory functionality. Where the DFL…