Another post for me that is simple and hopefully serves as an example for people trying to get blogging as#SQLNewBloggers.
One of the things I needed to do with my SQL Saturday download process was run this automatically. I don’t want to remember to do this, so I decided to set this up on a schedule.
I ran a quick search and it seemed to be a simple process. Essentially I run the Task Scheduler application and then call my script as a parameter to the PowerShell exe. The first step is to run Task Scheduler.
This has a list of jobs, which I found some to be interesting. I disabled Adobe and a few others. Those are really annoying. I clicked "Create a basic task".
The basic task is a wizard to walkthrough. First enter a name and description. Use something that will help you in 5 months when this breaks.
I decided to run this daily. It’s not a big deal to me, so I’ll let it just go.
The time doesn’t matter, and I let it run in the middle of the day. This way I might notice it running sometimes and that will motivate me to keep working on this process.
I want to run a program, so I choose that in the next step.
The dialog wants to know which program. In my case, I’ll have to browse to my PoSh code.
I pick my code and it puts the path in here. However that won’t run as is. If you’ve used PoSh, you know this doesn’t work.
What I need to do is call powershell.exe. I found this in the reference item below and what I do is add "powershell" to the front of my file, and then use the "-file" parameter. I also enclose my PoSh script in quotes.
When I click next, I get the warning, which I accept.
There’s a summary after this, but I say OK to that, and then run the script from the Task Scheduler. It works perfectly, so I stop there.
Now we’ll see how it works over time. And if I get the next step working.
SQLNewBlogger
This was a quick process for me. A google search, a 2 minute read, and then 2 minutes to build the task.
It took maybe 10 minutes to write this post, most of which was taking the screen shots and resizing them.
You can do this.
References
I just used one link, which was from the Scripting Guy blog.
- Weekend Scripter: Use the Windows Task Scheduler to Run a Windows PowerShell Script – http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx
Filed under: Blog Tagged: powershell, SQLNewBlogger, syndicated, windows