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!
Related
i believe the title is self explanatory.
The install-module isn't working anymore. I had it running earlier, but after downloading NuGet through powershell the module doesn't work anymore at all, giving me the error message shown in the title.
I'm running on Windows 10, Powershell Ver.: 5.1.16299.15.
The question has been asked before, but on other threads the problem was the Powershell version, which isn't the case for me.
Gotcha! - From above discussions,
Did you change $env:PSModulePath ? Nuget installation would not change it. You can add C:\Program Files\WindowsPowerShell\Modules in the list and try.
$env:PSModulePath += ';C:\Program Files\WindowsPowerShell\Modules'
I have created virtual machine in Azure and selected Windows Server 2012 R2.
I have installed windows PowerShell using the Web platform installer. When I try to run the following command:
Save-AzureRmProfile -Path C:\MyPath\myfile.json
It throws the error:
The term 'Save-AzureRmProfile' 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.
I have tried to follow this link here by adding environments variables but no help. Has anyone solved this issue?
Save-AzureRmProfile works on version 3.7. You could use the following cmdlet to check Azure PowerShell version.
Get-Module -ListAvailable -Name Azure -Refresh
You could download 3.7 version msi installer from this link.
You have to Install the Azure PowerShell cmdlets. I suggest you to install it using the latest MSI from this site.
It looks like the Save-AzureRmProfile cmdlet has been replaced by Save-AzureRmContext. I found that information here.
The name of the cmdlet was changed in 4.0, you can see all the changes in 4.0 here: https://github.com/Azure/azure-powershell/blob/preview/documentation/release-notes/migration-guide.4.0.0.md
Unfortunately, the name of the cmdlet was changed without an alias for backward compatibility in version 3.8, per this issue: . This is actually a bug we will be pushing out a version 3.9 which is identical to 3.8, except that the two profile cmdlets (Save-AzureRmProfile, Select-AzureRmProfile) remove this breaking change
Save-AzureRmContext and Import-AzureRmContext can be used for same purpose on Version 4.0
Usage is same!
I am trying to install the latest Azure PowerShell (released Nov. 9th 2015). If I try to install it using Web Platform Installer, I get the following error:
Azure Modules from the PowerShell Gallery are installed on this machine. Please remove these modules before installing this MSI.
If I run Get-InstalledModule in PowerShell, I see that the Module Azure (version 0.9.11) is installed. So I tried uninstalling it using the PowerShell command Uninstall-Module Azure. Here I get the following error:
PackageManagement\Uninstall-Package : The property 'ModuleBase' cannot be found on this object. Verify that the
property exists.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSGet.psm1:1351 char:21
+ ... $null = PackageManagement\Uninstall-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package],
Exception
+ FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage
Ok, I solved my problem. Stupid mistake: I was not running Uninstall-Module Azure as an admin. Once I started PowerShell with admin priviledges, uninstalling old Azure PowerShell was no problem.
Hm, would love to see a more descriptive error message in that case ;-)
I hit the same issue, but did not have anything Azure related appear when I executed Get-InstalledModule.
If you execute $env:PSModulePath in a powershell prompt it will list out all of your Module path locations, navigate to each of those and delete anything azure related and you should be able to install the new azure powershell cmdlets.
I'm running Windows 7 with PowerShell 2 installed.
I've downloaded version 2.1 from here - http://pscx.codeplex.com/releases
The Release notes say
unblock the zip file - {which I did}
extract the contents of the ZIP file to your $env:Home\Documents\WindowsPowerShell\Modules folder
I was unsure what $env:Home was so a bit of searching determined that the release notes are expecting an environment variable called Home which doesn't exist on my machine.
A bit more searching says use what is defined as ~ on my machine. So in a PS prompt I run cd ~
Which on my machine led to a network drive U:
I created the following directories U:\Documents\WindowsPowerShell\Modules and copied the extracted Pscx-2.1.0 to the Modules folder. Opened a PowerShell prompt and typed Get-Module -ListAvailable. This didn't give me Pscx in the results.
The above steps actually gave me this folder tree U:\Documents\WindowsPowerShell\Modules\Pscx-2.1.0\Pscx-2.1.0
So I copied the files up a level and tried again with U:\Documents\WindowsPowerShell\Modules\Pscx-2.1.0\ and also tried with U:\Documents\WindowsPowerShell\Modules\Pscx\
I also tried all of the above with this path U:\WindowsPowerShell\Modules\Pscx-2.1.0\
I'm guessing that the Modules aren't actually supposed to be in this directory, so a bit more searching leads to this command. (Get-ChildItem Env:\PSModulePath).Value
which gives the following result
C:\Users\my.name\Documents\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
So I copy the Pscx-2.1.0 folder to here C:\Users\my.name\Documents\WindowsPowerShell\Modules\Pscx-2.1.0
And still no luck.
What step am I missing?
I hadn't actually completed the last step of my above question completely which turned out to be the answer.
Here is that answer for completeness
Unblock the zip file you have downloaded
extract the zip file - this will likely give a folder structure of Pscx-2.1.0/Pscx-2.1.0/{lots of files}
rename the child folder to Pscx - ie - Pscx-2.1.0/Pscx/{lots of files}
In Powershell prompt run (Get-ChildItem Env:\PSModulePath).Value and note the modules folder location.
Copy the child Pscx folder to the Modules folder location given above.
In Powershell prompt run Get-Module -ListAvailable to see the Pscx module available.
In PowerShell 5.0, you can do:
Find-Package pscx | ? ProviderName -eq PSModule | Install-Package -Force
The -Force parameter will cause it to upgrade if an older version is already installed.
In PowerShell 5.1, you'll need:
Find-Package pscx | ? ProviderName -eq PowerShellGet | Install-Package -Force
or
Find-Package pscx -ProviderName PowerShellGet | Install-Package -Force
or just
Install-Package pscx -Force
Just run
choco install pscx
See chocolatey.org for a one-liner to get the choco command.
Keep in mind you may still have to call this in your scripts before running their commands:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser #allows scripts to run from the interwebs, such as pcsx
Update: Looks like PsGet is no longer maintained, but source is still available on github.
You can also use PsGet to easily search and install PowerShell modules.
You can check which modules have been added to PsGet by browsing for all modules:
> Get-PsGetModuleInfo *
Or locate this one specfically:
> Get-PsGetModuleInfo pscx
Then you can install based on that information:
> Install-Module pscx
After spending lot of time searching here and there, i found this blog has very clear steps to solve. try it may helps u ..
http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/18/install-the-pscx-and-80-new-cmdlets-to-ease-powershell-use.aspx
I'm trying to setup a large number of build agents and so far i can install all the dependencies silently (using powershell, nuget and chocolatey).
However i cannot install the tool IlMerge without the damn GUI popping up.
Ive tried all the usual msiexec switches and they are just ignored. does anyone know of a way of getting this tool on a box in an unattended way?
Or should i just repack the thing in zip/msi?
This is on windows server 2008 R2
If i run
Invoke-Expression "msiexec $installerPath\ilmerge.msi /passive"
I still get a security dialog.
Currently i'm just thinking ill do this:
Copy-Item x:\installs\ilmerge.exe "C:\Program Files (x86)\ILMerge"
seeing as its only one file.
Below worked for me, no security dialogs.
cp ILMerge.msi \\Server\admin$
winrs -r:Server ILMerge.msi /passive
dir "\\Server\C$\Program Files (x86)\Microsoft\ILMerge"
With chocolatey you would have just needed to specify -ia '/quiet' as the package was not silent by default. This was specified by the tag notSilent and it was also in the description (http://chocolatey.org/packages/ilmerge/2.11.1103.1).
The latest package is just the executable, so you can just install it. http://chocolatey.org/packages/ilmerge