Sunday, June 12, 2016

Run Powershell script from Gulp.js

Installation Requirement

  1. If your Visual Studio is 2013 or order install Task Runner Explorer - Download and install-
  2. Node.js- Recommended for most users-Check this download link-
  • Run from the cmd command from this solution or class library location.
  • Ensure you keep the gulp.js in location where the actions /events are required.
  • Run command below from Class Library or website folder: Npm I gulp -g

Change Environment variable path

Gulp .js can be run from Task Runner VS2015

var gulp = require("gulp");
var childProcess = require('child_process');

gulp.task('deploy-static-files', function (callback) {
    return childProcess.exec('Powershell.exe  -executionpolicy remotesigned -File  DeployStaticFiles.ps1', function (err, stdout, stderr) {
        if (err) console.log(err);


Powershell script :Deploy Static file code

####----Copy files from source to destination-----
$publishPathDestination      =   "Some Path"
$scriptpathSource            = Split-Path $MyInvocation.MyCommand.Path
Copy-Item  "$scriptpath"     $publishPathDestination   -Recurse -Force;

Post a Comment