Do you lose too much time to manually run your PowerShell Scripts every week? There is a wealth of frameworks, tools and products that offer you the ability to configure a Timer. However, Windows already contains a so-called Task Scheduler.
Index
PowerShell and the Task Scheduler
The Task Scheduler can be found via the Windows search:
Create Basic Task
Then, you need to create a new Basic Task:
Here you have to choose:
- how to call the task
- when to execute the task (trigger)
- and what action it should take
For example, I choose Daily …
… and select a time:
In addition, we want a program to start:
Now we have different possibilities. You can explicitly specify the path to PowerShell.exe or just write PowerShell.exe. I decided to go for the second option, because it seems easier to me.
Automating groups with PS? You should have a look at DynamicGroup. Everything is already set, stable, updated. Individual filters included. Here you can test it for free during 30-days.
Passing PowerShell arguments
Now it gets tricky. If parameters have to be passed to the PowerShell script, the Syntax is not easy to understand. But we get us to it.
Or written out:
1 |
-Command "&'C:\temp\TestScript.ps1'-p1'hallo'-p2'welt'" |
Call a new task
Then we can close the wizard. A new task is created and also visible in the task list:
The script is very simple. It only accepts the two parameters and writes them together into a text file:
1 2 3 4 5 |
Param( $p1, $p2 ) ($p1 + " " + $p2) | Out-File "C:\temp\test.txt" -Append |
The successful result:
Downsides or risks
You have to make sure it is running all the time. Individualization of the scripts takes time and of course you need PowerShell know-how. I just want to point out, that you have to share what you create with others, otherwise you might set up a black box. 🙂
Conclusion
It’s not difficult to create a simple task that schedules a PowerShell script. All you need to know is the slightly unfamiliar syntax that you can use to pass Powershell arguments. Once this is done, there is nothing in the way for further automation scenarios.
You still don’t want to spend time with PowerShell script for changing permissions ? The software DynamicGroup helps you to quickly and easily automate groups.
Delegation of tasks including PowerShell scripts? Have a look at IDM-Portal.
FirstAttribute AG – Identity Management & IAM Cloud Services
We would be happy to present our services and solutions to you. Get in touch and find out how we can help you.
Leave a Reply
<p>Your email is safe with us.<br/>Information about our <a href="https://activedirectoryfaq.com/contact-us/">data protection policies</a></p>