Categories
How-To Technical

Server 2008 R2, ‘Powershell’ is not recognized as an internal or external command …

While working on a task scheduling a powershell script, it was noticed that the powershell command does not execute from the command prompt on a server. When run I would encounter the following error: ‘powersehll’ is not recognized as an internal or external command, operable program or batch file.

After searching around Google / Bing I gave up and made the following attempt which worked out for myself and the system owners.

Looking at the system PATH variable seems correct with the expected path variable included under system variables: %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

I decided to check with my user only: I added ‘%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\’ to my user variable with success

In the systems path variables and removed the reference and added it to the end of the line which was successful in resolving the system wide issue.

Notes: This is a snapshot of before and after changes introduced which resolved my issue

original:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\

updated:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

Cause of issue is still unknown.  Perhaps an ordering issues in the variables.  If you know please feel free to comment.
Thanks,

Jermal

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.