Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell' is not recognized as an internal or external command, operable program or batch file

I am trying to run a powershell -Command to execute a powershell file as a post build event in Visual studio 2013 But i am getting

'Powershell' is not recognized as an internal or external command, operable program or batch file

error on output window and

Powershell -Command exited with code 9009 error 

Full Error Message:

'Powershell' is not recognized as an internal or external command, 10>  operable program or batch file. 10>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: The command "echo "C:\dev\tfs\Main\Shared\AggregationComponents\GenerateSchema.cmd" 10>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: call "C:\dev\tfs\Main\Shared\AggregationComponents\GenerateSchema.cmd" 10>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: echo "Move the PhoenixData namespace schema suffixing it" 10>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: Powershell -Command "C:\dev\tfs\Main\Shared\AggregationComponents\MoveAndRenameXsds.ps1 'C:\dev\tfs\Main\Shared\AggregationComponents\bin\Debug\' 'C:\dev\tfs\Main\Shared\AggregationComponents\..\PublishedAnalyticsXsds' '.Aggregation'"" exited with code 9009. ========== Rebuild All: 8 succeeded, 1 failed, 1 skipped ========== 
like image 217
Rahul Lodha Avatar asked Apr 21 '15 16:04

Rahul Lodha


People also ask

Why is PowerShell not working?

This error might pop up simply because the Windows PowerShell is disabled. So, you can tackle the issue by tweaking a few settings as follows: Type Turn Windows Features on or off in the Start Menu search bar and select the Best match. Locate the Windows PowerShell option and click its drop-down menu.

How do I run a PowerShell script from the command line?

Running a PowerShell script from the Command Prompt If you would like to run a PowerShell script in CMD, you'll need to execute it by calling the PowerShell process with the -File parameter, as shown below: PowerShell -File C:\TEMP\MyNotepadScript. ps1. PowerShell -File C:\TEMP\MyNotepadScript.


2 Answers

Sounds like you're missing an environment variable.

Add this to your Path environment variable:

%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\ 

OR

Change your script to this:

%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -Command "your command" 
like image 133
Jon Tirjan Avatar answered Sep 16 '22 13:09

Jon Tirjan


You only need to add it to your environment variables, just follow the following two simple steps:

1.write env in the search bar

or Right click start button -> System -> Advanced system settings -> Environment Variables... -> Select PATH

2. click on the new button and add the following path:

C:\WINDOWS\System32\WindowsPowerShell\v1.0\

or %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\


write env in the search bar

choose path

click Ok

like image 32
Mostafa Wael Avatar answered Sep 20 '22 13:09

Mostafa Wael