Thursday, July 25, 2013

Run all Powershell Scripts through batch file (.dat)

If you have many powershell scripts and you want to run all of those in a single click deployment
then use the below technique

1)Create a batch file  named "StartFile.bat"
2)Create a powershell script "PowershellFile.ps1" and add all your code in it
3)Edit the "StartFile.bat" and add the below piece of code

cd /d %~dp0
powershell.exe -File

4)Now save the changes
5)Run the batch file as Admin.
6)Your powershell script will be run

------------------------------------------------------------------------------------------------------------cd /d %~dp0
will open the powershell.exe from current location where the whole folder consisting of batch and powershell file is placed in a folder.

No comments:

Post a Comment