How to fix a broken Powershell installation?

on a Windows r2 sp1 server, I used chocolate to install the AWSTools.Powershell package. this, in turn, installed powershell 3. now, powershell is hopelessly broken, and I can’t figure out how it can be fixed or removed and reinstalled.

I'm afraid that my only answer is to completely rebuild the car, but I wanted to ask if there is a way to fix it.

powershell really works, it seems that it cannot find any of the built-in cmdlets. it seems that he finds pseudonyms, but cannot fulfill what is under them. for example, issuing ls to view the contents of a directory gives:

PS C:\Users\Administrator> ls ls : The term 'Get-ChildItem' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + ls + ~~ + CategoryInfo : ObjectNotFound: (Get-ChildItem:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException 

it may happen that in the beginning there is no execution of the script that sets up the environment. if you know more than me, and can provide some help and make sure that I do not have to rebuild this machine, I would be very pleased.

+6
source share
2 answers

A bit late for the game, but recently ran into this problem. I found that my PSModulePath did not include an important path. You can view your PSModulePath by running the following command:

$ ENV: PSModulePath

To add the required path, you can run this command:

$ env: PSModulePath = $ env: PSModulePath + "; C: \ Windows \ system32 \ WindowsPowerShell \ v1.0 \ Modules \"

+10
source

This is a very old thread, but since I found it, although I was looking for the same problem, I thought I mentioned how I solved it.

First, the problem is how I survived it:

I had PowerShell 2.0 in Windows 7, then choco was used to install / upgrade in PowerShell 4.0:

 choco upgrade powershell 

This upgraded my system to 4.0, but when I opened PowerShell, the update broke most of the basic cmdlets, such as Get-ChildItem (aka dir).

After I worked a bit on the Internet, I decided to reinstall it from the MS website ... but first I removed it from choco.

 choco uninstall powershell 

And since it was a choco that broke it to start, I thought I would give another attempt to install it with the following command:

 choco install powershell --force 

And low, this fixed the problem. So I stopped. Hope this helps someone. Good luck

+3
source

Source: https://habr.com/ru/post/949465/


All Articles