Unable to find module providers - windows

I'm having an issue with PowerShell. It's almost like it's not installed all the way; which is weird since it's Windows 10 and it ships with it.
With no lock, I've tried replacing the following directories with a fresh copy from another Windows 10 machine that is working:
C:\Users\UserName\AppData\Local\PackageManagement
C:\Program Files\WindowsPowerShell
C:\Program Files (x86)\WindowsPowerShell
C:\Windows\System32\WindowsPowerShell
I also tried SFC /scannow, but it found no issues. I've searched for hours and haven't been able to find anyone with the exact same issue. Does anyone have any ideas?
System Information:
PS C:\WINDOWS\system32> [environment]::OSVersion.Version
Major Minor Build Revision
----- ----- ----- --------
10 0 10586 0
PS C:\WINDOWS\system32> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10586 122
Errors:
PS C:\WINDOWS\system32> Get-PSRepository
PackageManagement\Get-PackageSource : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:3544 char:31
+ ... ckageSources = PackageManagement\Get-PackageSource #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument:(Microsoft.Power...etPackageSource:GetPackageSource) [Get-PackageSource
], Exception
+ FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource
PS C:\WINDOWS\system32> Get-PackageProvider -Name PSModule -ForceBootstrap
Get-PackageProvider : Unable to find package provider 'PSModule'. It may not be imported yet. Try 'Get-PackageProvider
-ListAvailable'.
At line:1 char:1
+ Get-PackageProvider -Name PSModule -ForceBootstrap
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...PackageProvider:GetPackageProvider) [Get-PackageProvi
der], Exception
+ FullyQualifiedErrorId : UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPacka
geProvider
The below returns nothing:
PS C:\WINDOWS\system32> Get-PackageProvider -ListAvailable
PS C:\WINDOWS\system32>

If your end goal is to install packages from Chocolatey or something similar with PowerShell you would want to perform the following.
To import the Module you would execute the following:
Import-Module PackageManagement
To install the package providers you would execute the following:
Install-PackageProvider -Name Chocolatey -Force
To find a package within the package provider Chocolatey you would execute the following (you could use wildcard for name to get all packages available):
Find-Package -Name SomePackageNameHere -ProviderName Chocolatey
Lastly, to install a package from Chocolatey you would execute the following:
Install-Package -Name SomePackageNameHere -ProviderName Chocolatey -Force
I hope this helps!

Looks like I solved the issue. I installed Chocolatey by using the CMD.exe method.
I ran CMD.exe as an administrator and ran the following command:
#powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
Now I have a PS Repository:
PS C:\WINDOWS\system32> Get-PSRepository
Name PackageManagementProvider InstallationPolicy SourceLocation
---- ------------------------- ------------------ --------------
PSGallery NuGet Untrusted https://www.powershellgallery.com/api/v2/
I'm guessing something during the install of Chocolatey, repaired whatever was broken.

Related

How to install Cypress from local zip file using npm

I wanted to install Cypress using npm - but my corporate firewall is blocking.
So I tried the below method in my Terminal in Visual Studio Code - But getting an error (pasted below)
Any idea on why this script does not work? and solution to it?
PS C:\Users\c64881a\Desktop\NPM_Cypress> CYPRESS_INSTALL_BINARY=C:/Users/c64881a/Downloads/cypress.zip npm install cypress
CYPRESS_INSTALL_BINARY=C:/Users/c64881a/Downloads/cypress.zip : The term 'CYPRESS_INSTALL_BINARY=C:/Users/c64881a/Downloads/cypress.zip' 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
CYPRESS_INSTALL_BINARY=C:/Users/c64881a/Downloads/cypress.zip npm ins ...
+ CategoryInfo : ObjectNotFound: (CYPRESS_INSTALL...ads/cypress.zip:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Please, try this in PowerShell:
setx CYPRESS_INSTALL_BINARY C:/Users/c64881a/Downloads/cypress.zip

Error while installing kubectl in Windows 10

Installing the kubectl on windows 10 not working. I follow this URL.
I tried different install options, in the powershell and using chocolote. None of them worked for me. The error is clear that this execuable is not supported for windows os. I did checked the SHA but it is different.
PS D:\chocoloate_tmpdir> curl -o kubectl.exe.sha256 https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/windows/amd64/kubectl.exe.sha256
PS D:\chocoloate_tmpdir> Get-FileHash kubectl.exe
Algorithm Hash Path
--------- ---- ----
SHA256 02F984988E490046CBC831A582D34505C28C7DD9AB61C357E264C7178596B701 D:\chocoloate_tmpdir\kubectl.exe
PS D:\chocoloate_tmpdir> Get-FileHash .\kubectl.exe.sha256
Algorithm Hash Path
--------- ---- ----
SHA256 98BCEB6AF839704828C28709B60628E25CF5F624A6D6E7D06F1FC255AA4254CB D:\chocoloate_tmpdir\kubectl.exe.sha256
question is, what could be the issue and what other methods are available for installing kubectl in windows.
Here are the commands tried and error output:
one:
PS D:\chocoloate_tmpdir> choco install kubernetes-cli Chocolatey v0.10.15
Installing the following packages:
kubernetes-cli
By installing you accept licenses for the packages.
Progress: Downloading kubernetes-cli 1.17.1... 100%
kubernetes-cli v1.17.1 [Approved]
kubernetes-cli package files install completed. Performing other installation steps.
The package kubernetes-cli wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): Y
Extracting 64-bit C:\ProgramData\chocolatey\lib\kubernetes-cli\tools\kubernetes-client-windows-amd64.tar.gz to C:\ProgramData\chocolatey\lib\kubernetes-cli\tools...
C:\ProgramData\chocolatey\lib\kubernetes-cli\tools
Extracting 64-bit C:\ProgramData\chocolatey\lib\kubernetes-cli\tools\kubernetes-client-windows-amd64.tar to C:\ProgramData\chocolatey\lib\kubernetes-cli\tools...
C:\ProgramData\chocolatey\lib\kubernetes-cli\tools
ShimGen has successfully created a shim for kubectl.exe
The install of kubernetes-cli was successful.
Software installed to 'C:\ProgramData\chocolatey\lib\kubernetes-cli\tools'
Chocolatey installed 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
PS D:\chocoloate_tmpdir> kubectl version --client Program 'kubectl.exe' failed to run: The specified executable is not a valid application for this OS platform.At line:1 char:1
+ kubectl version --client
+ ~~~~~~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ kubectl version --client
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
two:
PS D:\chocoloate_tmpdir> curl -o kubectl.exe https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/windows/amd64/kubectl.exe
PS D:\chocoloate_tmpdir> cp .\kubectl.exe C:\bin\
PS D:\chocoloate_tmpdir> kubectl version Program 'kubectl.exe' failed to run: The specified executable is not a valid application for this OS platform.At line:1 char:1
+ kubectl version
+ ~~~~~~~~~~~~~~~.
At line:1 char:1
+ kubectl version
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
You've probably missed some of these steps:
Copy the binary to a folder in your PATH. If you have an existing
directory in your PATH that you use for command line utilities, copy
the binary to that directory. Otherwise, complete the following steps.
Create a new directory for your command line binaries, such as C:\bin.
Copy the kubectl.exe binary to your new directory.
Edit your user or system PATH environment variable to add the new directory to your PATH.
Close your PowerShell terminal and open a new one to pick up the new PATH variable.
Please verify what is the current content of your PATH. You can move your kubectl binary directly to one of those folders which are already added to your PATH. Alternatively you may edit it and add your desired directory containing kubectl. Have you relaunched your PowerShell terminal after saving the changes ? It's quite straightforward to configure and there is no need to use full paths to the executable.
Take a look at this article in the official kubernetes docs.
Please let me know if it helps.
Calling the command from the current path does the trick. I have added the executable to c:\bin path and added the path to system environment variable, somehow it was not set, not sure why. Its an issue with the execuable being not found in the path.
PS D:\chocoloate_tmpdir> kubectl version Program 'kubectl.exe' failed to run: The specified executable is not a valid application for this OS platform.At line:1 char:1
+ kubectl version
+ ~~~~~~~~~~~~~~~.
At line:1 char:1
+ kubectl version
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
PS D:\chocoloate_tmpdir> .\kubectl.exe version Client Version: version.Info{Major:"1", Minor:"14+", GitVersion:"v1.14.7-eks-1861c5", GitCommit:"1861c597586f84f1498a9f2151c78d8a6bf47814", GitTreeState:"clean", BuildDate:"2019-09-24T22:12:08Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"windows/amd64"}
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.

Why is 7-Zip failing during this Chocolatey installation on Windows 10?

I am trying to install Chocolatey
https://chocolatey.org/install
and using the command:
#"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
It is showing error:
Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install
again. Error: 7-Zip encountered a fatal error while extracting the files
At line:221 char:9
+ 2 { throw "$errorMessage 7-Zip encountered a fatal error while ex ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Unable to unzip...cting the files:String) [], RuntimeException
+ FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompres
sion = 'true' and call install again. Error: 7-Zip encountered a fatal error while extracting the files
I have 7zip installed.
I encounter the same issue.
Running window cmd as administrator may be a solution for some but in my case i had to update my window system environment variable,
I just added this to exiting value on
path: $env:chocolateyUseWindowsCompression = 'true'
and all works just fine.
I had the same error when I was trying to install chocolatey on multiple servers which was finally getting blocked at chocolatey server, which is a chocolatey feature.
https://chocolatey.org/docs/community-packages-disclaimer#rate-limiting
Hence the downloaded file is null and cannot be unzipped. The block is lifted an hour later. After rate limit is lifted, the errors disappears until you trigger it again.
Rate limiting also applies to other packages. When limit is hit while downloading a package other than chocolatey itself, you will get an error code 429.
https://chocolatey.org/docs/troubleshooting#im-getting-a-429-too-many-requests-issue-when-attempting-to-use-the-community-package-repository
First answer: Running window cmd as administrator may be a solution for some but in my case i had to update my window system environment variable, I just added this to exiting value on path: $env:chocolateyUseWindowsCompression = 'true' and all works just fine.
may not work immediately and you still receive "Unable to unzip package using 7zip." error.
Try again after restarting your machine. In my case command works after restarting.
Thx
karam
After a few months, i ran the same command from cmd with Administrative Privilege and it worked. The main point was running
cmd.exe As an Administrator.

nuget powershell: cant run build independent updates

I am trying to update a package through the package manager console with a command like this:
update-package Package.Name -version 9.27
However this does not seem to work because the package has a lot of build information behind it like so:
-version 9.27.5146.3567
I would like to get the latest build version of package version 9.27 without constantly selecting the lastest build.
So far I have tried:
update-package Package.Name -version 9.27.*
update-package Package.Name -version 9.27.*.*
update-package Package.Name -version 9.27 -safe
Note: I can't just update to the latest version of Package.Name It has to be specific 9.27.[latest build]
Not sure if there is an easier way, but this one-liner should work:
Update-Package Package.Name -Version ((Find-Package Package.Name -ExactMatch -AllVersions).Versions | where {$_ -like "9.27.*"} | sort | select -Last 1)

System cannot find path specified when installing .exe and .msi silently

I am trying to install my .exe after downloading them into:
wget "https://github.com/git-for-windows/git/releases/downloadv2.13.1.windows.2/Git-2.13.1.2-64-bit.exe" -outfile c:\Windows\System32\Bradford\Git-2.13.1.2-64-bit.exe
However, when I try to install it silently, without human interaction:
C:\Windows\System32\Bradford\Git-2.13.1.2-64-bit.exe /s /v"/qn"
I am getting this error:
The system cannot find the path specified.
Also I do not know how to install a .msi file silently as well. In this case, nodeJS
I am using a AWS instance instance. Specifically:
Microsoft Windows Server 2012 R2 with SQL Server Express - ami-37b39552
Microsoft Windows Server 2012 R2 Standard edition, 64-bit architecture, Microsoft SQL Server 2016 Express edition. [English]
The easiest way I know how to do this is with Chocolatey.
I have some cloud servers that need various Chocolatey packages, and I do (something like) the following to install them. I have installed Git this way before, and it is a completely unattended / silent install.
Here's a short script that handles installing and configuring Chocolatey, installing Git, and updating the %PATH%.
<#
.description
Get the PATH environment variables from Machine, User, and
Process locations, and update the current Powershell
process's PATH variable to contain all values from each of
them. Call it after updating the Machine or User PATH value
(which may happen automatically during say installing
software) so you don't have to launch a new Powershell
process to get them.
#>
function Update-EnvironmentPath {
[CmdletBinding()] Param()
$oldPath = $env:PATH
$machinePath = [Environment]::GetEnvironmentVariable("PATH", "Machine") -split ";"
$userPath = [Environment]::GetEnvironmentVariable("PATH", "User") -split ";"
$processPath = [Environment]::GetEnvironmentVariable("PATH", "Process") -split ";"
$env:PATH = ($machinePath + $userPath + $processPath | Select-Object -Unique) -join ";"
Write-EventLogWrapper -message "Updated PATH environment variable`r`n`r`nNew value: $($env:PATH -replace ';', "`r`n")`r`n`r`nOld value: $($oldPath -replace ';', "`r`n")"
}
# Install Chocolatey itself:
Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression
# NOTE: Chocolatey changes the system %PATH%, so we have to get the latest update here:
Update-EnvironmentPath
# Configure Chocolatey to not require confirmation when installing packages:
choco.exe feature enable --name=allowGlobalConfirmation --yes
# Install the package we care about
choco.exe install git
# Installing Git also changes the system %PATH%, so we have to update it again:
Update-EnvironmentPath

Resources