Help! Can’t Get PowerShell to Work Properly

0
0
Asked By CuriousCat77 On

Hey everyone! I'm super new to PowerShell and I've been trying to figure it out. I used to be able to download stuff from GitHub without any issues, but now I'm having a total meltdown. Whenever I try to run any command, I get the same error message saying that 'pwsh.exe' is not recognized as a command, script, or executable. I was just trying to update PowerShell, hoping that would fix things, but even that's not working!

I've tried checking my execution policy and running a script called 'Get-TimeService.ps1', but I got similar errors saying it can't find the script. It's frustrating because I feel like I'm going in circles. If anyone can guide me through this, I'd really appreciate it!

3 Answers

Answered By TechGuru99 On

It sounds like 'pwsh.exe' might not be installed on your system, which is why you're getting that error. The PowerShell you're trying to use is likely the Windows version that came with your OS, but you need to install PowerShell Core separately. For your script issue, it seems like you're trying to run 'Get-TimeService.ps1' from the wrong directory. Make sure the script is in the folder you're currently in. Try changing your directory to where the script is actually located, like this:

PS > cd "C:UsersYourUsernameDesktop"
PS > .Get-TimeService.ps1

Also, using the Tab key for autocompletion can really save you time and help check if you're on the right track!

HelpfulHarry22 -

When I type `cd "C:UsersYourUsernameDesktop"`, I just get a `>>` and nothing else. What does that mean?

NerdyNora33 -

I tried to install PowerShell Core, but I'm getting the same error for 'winget' command as well.

Answered By ExplorerX On

You seem to be running your commands from "C:windowssystem32". The './' means you're trying to run a script from your current directory. It looks like 'Get-TimeService.ps1' is not found in System32. Make sure the script is actually in that folder. Try locating where it is saved and change directories accordingly!

HelpfulLinkAngel -

Check out these resources for managing current locations and scripts: https://learn.microsoft.com/en-us/powershell/scripting/samples/managing-current-location?view=powershell-7.5

Also, this one for scripts: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scripts?view=powershell-7.5

Answered By ScriptSage On

Are you using PowerShell 7? That 'pwsh.exe' syntax only works in that version. If you're not sure, you might want to check what version you have. Also, it's sometimes helpful to run the first few lines of your script manually to see if you can catch any better error messages.

ConfusedCoder55 -

I followed the install instructions for PowerShell 7, so I don’t understand why the command would only work in 7 but I need it to install!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

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