on a windows server 2008 r2 sp1 machine, i used chocolatey to install the AWSTools.Powershell package. this, in turn, installed powershell 3. now, powershell is hopelessly broken and i can't figure out any way of fixing it or uninstalling and reinstalling it.
i fear my only answer is completely rebuilding the machine, but wanted to ask if there's a way to fix it.
powershell actually runs, it just seems it can't find any of the build-in cmdlets. it seems it does find aliases, but can't execute what's under them. for example, issuing an ls to look at directory contents yields:
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 be that there's just some execution of some script missing at the start that sets up the environment. if you know more than me and can offer some assistance and can make it so that i don't have to rebuild this machine, i would be very happy.
A little bit late to 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 this command:
$env:PSModulePath
To add the needed path you can run this command:
$env:PSModulePath = $env:PSModulePath + ";C:\Windows\system32\WindowsPowerShell\v1.0\Modules\"
This is a very old thread, but since I found it whilst troubleshooting the exact same issue - I thought I'd mention how I resolved it.
First the problem as I experienced it:
I had PowerShell 2.0 on Windows 7, then used choco to install/upgrade to PowerShell 4.0:
choco upgrade powershell
That updated my system to 4.0, but when I opened PowerShell, the upgrade broke most of the basic cmdlets such as Get-ChildItem (aka dir).
After fumbling about online for a while, I thought I'd reinstall from the MS Website... but first I uninstalled from choco.
choco uninstall powershell
And since it was choco that broke it to begin with I thought I'd give it one more try to install cleanly with the following command:
choco install powershell --force
And low, that fixed the problem. So I stopped there. Hopefully that's helpful to someone. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With