Drupal – Run Drush in Windows PowerShell

1. Install the Drush Windows Installer.

2. Open the DrushEnv.bat in a text editor. The default location should be C:\Program Files (x86)\Drush. You should see the ENV variable setting as follow.

@ECHO Command Prompt shell optimized for Drush 
@SET PATH=%PATH%;C:\ProgramData\Drush\
@SET PATH=%PATH%;C:\Program Files (x86)\Drush\GnuWin32\bin
@SET PATH=%PATH%;C:\Program Files (x86)\Drush\Php


3. Follow Windows PowerShell – Setup user account profile to setup your PowerShell profile.

4. Set the PATH as highlighted below.

# Set the default path
#set-location c:\

# Get the shell window
$shell = $Host.UI.RawUI

# Set the shell title

# Set color theme
$shell.BackgroundColor = "Black"
$shell.ForegroundColor = "White"

# Set the shell window size
$size = $shell.WindowSize
$shell.WindowSize = $size

# Set the shell buffer size
$size = $shell.BufferSize
$shell.BufferSize = $size

$env:Path += ";C:\ProgramData\Drush"
$env:Path += ";C:\Program Files (x86)\Drush\GnuWin32\bin"
$env:Path += ";C:\Program Files (x86)\Drush\Php"

# Setup alias to start the text editors by commands
new-item alias:np -value "C:\Windows\System32\notepad.exe"
new-item alias:sublime -value "C:\Program Files\Sublime Text 2\sublime_text.exe"

# Clear the shell


5. Restart PowerShell and your Drush command should work.

Done =)

Reference: StackOverflow – Setting windows powershell path variable


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s