While I'm sure that your own solution helped, it's worth digging deeper:
The dotnet
and .dotnet\tools
folders are present in PATH
To produce your symptom, the former must be true, but not the latter:
It is dotnet.exe
that issues the error message (implying that dotnet.exe
itself indeed is in the PATH).
The error message indicates that a tool named script
could not be located, implying that an executable named dotnet-script.exe
could not be found in the PATH, because that's the executable name that dotnet
constructs behind the scenes when you call dotnet script
.
With a properly set up PATH (and, of course, dotnet-script installed), dotnet-script.exe
should be found via the $HOME\.dotnet\tools
directory in the PATH.
$HOME\.dotnet\tools
is an entry stored as part of the user-specific PATH additions in the registry, and your PowerShell session seemingly hadn't picked up that entry yet - which can happen for the reasons mentioned in your answer.