Cannot run script in Powershell or cmd

kobosh 176 Reputation points
2021-07-22T21:01:04.423+00:00

I am following through with thistable-of-contents

Pluralsight course. I try to run script called restore.cmd @ECHO OFF SETLOCAL PowerShell -NoProfile -NoLogo -ExecutionPolicy ByPass -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' -all -nobuild -restore %*; exit $LASTEXITCODE"
When I type restore.cmd either in Powershell or windows cmd I get error:

'PowerShell' is not recognized as an internal or external command,
operable program or batch file.
I cloned aspnetcore source code from github and went through steps as in video but was stuck at the step to restore packages to build the solution.
My question first about this command (restore.cmd) is it powershell script? what is it doing?
and why I am getting the error? and is there any workaround like copying the command and run it in nugetconsole in visual studio

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,532 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ian Xue 37,106 Reputation points Microsoft Vendor
    2021-07-23T05:57:32.03+00:00

    Hi,

    The path of PowerShell cannot be found on your machine. Please check the PATH environment variable by running echo %path% in cmd. If the path of powershell.exe "C:\WINDOWS\System32\WindowsPowerShell\v1.0\" is not contained, you can run "env" from the start menu and add it to the Path system variable.

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Rich Matheisen 46,796 Reputation points
    2021-07-22T21:13:46.03+00:00

    Assuming you're running this on Windows this should be in your Path environment variable:

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

    You should find "powershell.exe" in that directory.

    0 comments No comments

  2. kobosh 176 Reputation points
    2021-07-23T14:51:17.267+00:00

    Sorry for Richmatheisen-8865 your answer is also accepted and you were the first

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.