Is there a tool that can convert a batch file into a powershell script?
My issue I'm having with batch files is that they are not running from the task scheduler, unless I stay logged in, and I'm hoping that a conversion to Powershell may obviate this.
73 Answers
At this time there's no magic converter. However, there are tools you can utilize that will help you convert your batch scripts. One such tool is the Powershell ScriptoMatic.
To run or convert batch files externally from powershell (particularly if you wish to sign all your scheduled task scripts with a certificate) I simply create a powershell script e.g deletefolders.ps1
Input the following into the script:
cmd.exe /c "rd /s /q C:#TEMP\test1"
cmd.exe /c "rd /s /q C:#TEMP\test2"
cmd.exe /c "rd /s /q C:#TEMP\test3"
*Each command needs to be put on a new line calling cmd.exe again.
This script can now be signed and run from powershell outputing the commands to command prompt / cmd directly.
A much safer way then running batch files!
This is easily fixed. create a group, and user in that group, as a service account. I actually called mine service.account. Make the task run as this user. No matter what you use, batch, vb, powershell, etc, it will run. Now, you need to setup the account to secure against it being used by someone, using policy and some very simple methods. Use a log on script for the account that logs when this account is used, where it is used, and what time, etc....Setup a script that collects and stores this log, (straight text is best) and deletes upon a certain age. It takes a little watching, but youll know if it gets used. Do not share your task account info with ANYONE who doesnt absolutely need it. My techs did not know what mine were. Because at one point early in the pit we all call systems security, I did share it with a tech that would not allow the tech to have admin access on the box, it spread like wildfire.
3