Task scheduler : Executing powershell script from a specific folder


Say you have a powershell scripts that reference other .net assemblies in a folder and you need to have a task scheduler to run it, you might run into "unable to find reference type" error. 

The solution is really simple, basically run powershell, change directory to the folder and execute your script. 

Here is a quick way to do it via a windows batch file and you probably have something like this setup. 




And then here comes the scripts. What this scripts does is, start powershell, use push-location to change directory and then execute your script. Noticed I added a "-noexit" flag to stop powershell to close execution window.






Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm