question

kobosh-5924 avatar image
0 Votes"
kobosh-5924 asked kobosh-5924 answered

Cannot run script in Powershell or cmd

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered IanXue-MSFT edited

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

kobosh-5924 avatar image
0 Votes"
kobosh-5924 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

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.







5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.