Share via

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 for business | Windows Server | User experience | PowerShell
0 comments No comments

Answer accepted by question author

Anonymous
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.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. 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

    Was this answer helpful?

    0 comments No comments

  2. Rich Matheisen 48,116 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.

    Was this answer helpful?

    0 comments No comments

Your answer

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