Schedule powershell script

Sometimes it’s necessary to run powershell scripts on regular time. Just create a normal Windows scheduled job and insert the command below

Powershell -command “& ‘c:\scripts folder\myscript.ps1′”

Ok.. but why this simple action is post? Well sometimes after having run this task the “Task Run Result” shows you that the task has run correctly but not all the commands in your script completed. What’s going on here, man?

Well the task runs correctly, and after the script was executed the OS closes the Powershell session and does not wait.. So to prevent this behaviour (as like at so many Sharepoint cases) let’s insert a start-sleep -seconds 5 command at the end of your pws script 🙂


“powershell scheduled task”


Domain Join using PowerShell V2.0 Part I

In the time of IaaS (Infrastructure as a Service) and cloud computing, provisioning of new servers by one click should not be a problem. And when we’re talking about cloning virtual machines (vmdk / vhd) that’s true for sure. But what about the necessary post steps after the VM and Operating System is ready? For example joining the windows server to any domain automatically? Many companies still do these steps by hand. Of course, if we work for a large one, we probably already have tools to save some time on these post-steps (e.g. if you have a vCenter Server, you can use the “deploy virtual machine from this template” function, which has some built-in tricks like domain join). But these tools are usually just trigger some built-in Windows mechanism like sysprep.

What happens if we want our own, customized solution which is probably better than the commercial ones? Then it’s time to write our own post-script tool set, and use these scripts to automate our work.

Let’s start with the automatic domain join.

Continue reading “Domain Join using PowerShell V2.0 Part I”