I am following the Chocolately Install steps (Windows 7), but have run into a couple of problems.
Firstly, I've opened Command Prompt (opening it with Run as administrator), but when trying to execute Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')), I get this error:
Uncaught SyntaxError: Unexpected identifier
..with the https: part of my command highlighted.
Further, when I try to execute Get-ExecutionPolicy, it results in:
Uncaught ReferenceError: Get is not defined
Any ideas what could be wrong?
* UPDATE *
When I try the same command in PowerShell, I get this error:
PS C:\Users\mylogin> Set-ExecutionPolicy Bypass -Scope Process -Force;
[System.Net.ServicePointManager]::SecurityProtoc ol =
[System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex
((New-Object System.Net.WebClient).DownloadString
('https://chocolatey.org/install.ps1')) Exception setting
"SecurityProtocol": "Cannot convert value "3312" to type
"System.Net.SecurityProtocolType" due to inv alid enumeration values.
Specify one of the following enumeration values and try again. The
possible enumeration values are "Ssl3, Tls"." At line:1 char:85
+ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]:: <<<< SecurityProtocol = [System.
Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object
System.Net.WebClient).DownloadString('https://ch
ocolatey.org/install.ps1'))
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
Exception calling "DownloadString" with "1" argument(s): "The
underlying connection was closed: An unexpected error occ urred on a
send." At line:1 char:219
+ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.Se
rvicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object
System.Net.WebClient).DownloadString <<<< ('https://ch
ocolatey.org/install.ps1'))
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Download chocolatey latest version from Chocolatey.org
Rename file extension to .zip
Extract the file
Open PowerShell
Open elevated PowerShell calling:
Start-Process powershell -Verb runAs
Go to the tools folder in the location where you extracted Chocolatey
Call: & .\chocolateyInstall.ps1 to allow Chocolatey to install
Add a path to the choco location to system environment PATH:
C:\ProgramData\chocolatey\bin
Restart your consoles, and VS Code (if you use one)
Chocolatey.org requires TLS 1.2 to be able to connect. This error indicates that you don't have support for that installed:
System.Net.WebClient).DownloadString ('https://chocolatey.org/install.ps1')) Exception setting "SecurityProtocol": "Cannot convert value "3312" to type "System.Net.SecurityProtocolType" due to inv alid enumeration values. Specify one of the following enumeration values and try again. The possible enumeration values are "Ssl3, Tls"
The section from the blog post I linked to earlier should help:
If you find yourself provisioning machines such as Windows 7, Windows Server 2008, or older, you will find that those machines will not be able to communicate with the Chocolatey Community Repository after we implement this change. For those instances, you will need to use alternative installation methods for Chocolatey. We strongly recommend using the offline Chocolatey installation as it provides the most flexibility and reliability.
On the Chocolatey install page the requirements are listed:
Windows 7+ / Windows Server 2003+
PowerShell v2+ (minimum is v3 for install from this website due to TLS 1.2 requirement)
.NET Framework 4+ (the installation will attempt to install .NET 4.0 if you do not have it installed)(minimum is 4.5 for install from this website due to TLS 1.2 requirement)
My suggestion would be to fully patch your Windows 7 system, install .NET 4.5 and then try it. Remember Windows 7 has been out of support since January this year.
Related
I want to build a new project using sanity. I tried this command - npm install -g #sanity/cli and it was successfully installed. But when I tried this command - sanity init --coupon javascriptmastery2022, I get the following error:
sanity : File C:\Users\asus\AppData\Roaming\npm\sanity.ps1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ sanity init --coupon javascriptmastery2022
+ ~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Now how should I fix this error?
Start powershell as administrator and go to the folder where you want to install sanity.
Type: Set-ExecutionPolicy -Scope CurrentUser
Then change to Unrestricted
It should work now
Run this command in bash in the backend Sanity folder
I recently upgraded my Windows 10 to version 1903, but after some issue and contacting Microsoft technical support, I've reset my Windows. Now I'm trying to reinstall everything that was installed before reset and one of them is Chocolatey (The package manager for Windows).
I tried running both installation command:
(for cmd)
#"%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"
(for PowerShell)
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
but every time I get this error:
Exception calling "Start" with "0" argument(s): "The specified executable is not a valid application for this OS
platform."
At C:\Users\ehsan\Downloads\install.ps1:206 char:3
+ $process.Start() | Out-Null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : Win32Exception
Exception calling "BeginOutputReadLine" with "0" argument(s): "StandardOut has not been redirected or the process
hasn't started yet."
At C:\Users\ehsan\Downloads\install.ps1:207 char:3
+ $process.BeginOutputReadLine()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
Exception calling "WaitForExit" with "0" argument(s): "No process is associated with this object."
At C:\Users\ehsan\Downloads\install.ps1:208 char:3
+ $process.WaitForExit()
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install
again. Error: 7-Zip signalled an unknown error (code )
At C:\Users\ehsan\Downloads\install.ps1:220 char:15
+ ... default { throw "$errorMessage 7-Zip signalled an unknown error (co ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Unable to unzip...n error (code ):String) [], RuntimeException
+ FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompres
sion = 'true' and call install again. Error: 7-Zip signalled an unknown error (code )
I also tried downloading the install.ps1 scripts and running it manually (after setting execution policy to bypass, for sure), but the result was the same as above. Worth mentioning that I ran both cmd and PowerShell as administrator for installation. By the way, I didn't try offline installation yet, because I cannot figure out what the instruction says.
Googling the error didn't help me find a solution.
I had this same problem (at least the message was exactly the same). I was installing chocolatey in a more controlled environment, that is, some parts of the scripts are not allowed to be performed by some security policy reason.
The error is that on line 192 of the PowerShell, it's attempted to download an EXE file:
Download-File 'https://chocolatey.org/7za.exe' "$7zaExe"
This is not allowed in my environment, so as I have the Zip already installed on my Windows, I just copy the and renamed the needed file (7az.exe) to the folder that the install.ps1 (Powershell script) was looking for.
In my case:
C:\Users\%USER%\AppData\Local\Temp\chocolatey\chocInstall\7za.exe
So, having the ZIP exe file at this path, with this name, everything worked.
Cheers
Code sample:
$UpdateSession = New-Object -ComObject 'Microsoft.Update.Session'
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
$Updates = $UpdateSearcher.Search('IsInstalled=1')
$Updates | Where-Object { $_.Title -like '*KB2506143*' }
I'm trying to uninstall WMF3 programmatically, but I keep getting errors when trying to utilize wusa.exe,
wusa /uninstall /kb:2506143 /quiet /norestart /log:C:\log.evt
CbsClient::CbsClient.00110: Failed to create a CBS session instance
CbsClient::CbsClient.00127: Exit with error code 0X80040154 (Class not registered)
UninstallWorker.00664: Start of search
CbsClient::OpenPackageByKB.00268: CBS session is not initialized.
CbsClient::OpenPackageByKB.00320: Exit with error code 0X8000ffff (Catastrophic failure)
UninstallWorker.00667: Failed: OpenPackageByKB() for KB2506143
UninstallWorker.00799: Exit with error code 0X8000ffff (Catastrophic failure)
RebootIfRequested.01446: Reboot is not scheduled. IsRunWizardStarted: 0, IsRebootRequired: 0, RestartMode: 1
Windows update could not be uninstalled because of error 2147549183 "Catastrophic failure" (Command line: "C:\windows\System32\wusa.exe /uninstall /kb:2506143 /quiet /norestart /log:C:\log.evt")
wWinMain.01962: Failed to uninstall update ; Error: 0X8000ffff, Catastrophic failure. Command line: C:\windows\System32\wusa.exe /uninstall /kb:2506143 /quiet /norestart /log:C:\log.evt
wWinMain.01998: Exit with error code 0X8000ffff (Catastrophic failure)
so I'm pursuing using the WUA API. The above code snippet gives me a $Null return, but I can use Get-Hotfix -ID KB2506143 or Get-WmiObject -Class Win32_QuickFixEngineering -Filter 'HotFixID="KB2506143"' to find the update.
This question is similar, but it's getting access denied when trying to uninstall the patch after it has already been found, while my question is: how do I find the patch in the first place?
I'm not sure how the patch got applied, so if I run into the same issue once I find it, I have that resolution at least.
So the purpose of all this was to upgrade to WMF5.1 programmatically and I found a workaround for what I was trying to accomplish. PowerShell v3 was enabled in the OS using DISM during the build process and cannot be removed by WUA because it wasn't placed there by WUA.
Workaround 1:
dism.exe /Online /Disable-Feature:MicrosoftWindowsPowerShellV3
This downgrades $PSVersionTable to v2, but it does not remove the patch KB2506143. This causes the need to uninstall it through the UI manually still so it didn't really accomplish what I need.
Workaround 2:
WMF3 cannot be upgraded to WMF5, but it can be upgraded to WMF4, then WMF5(.1).
Ultimately, I installed WMF4 over WMF3 with wusa.exe while still disabling v3 in dism for good measure and was successful installing WMF5.1 over WMF4 after a reboot (again, with wusa.exe).
The limitation is rooted with the WUA not being able to manage patches that it did not install (through a .msu or WSUS)
I'm trying to update a (root) certificate's friendly name through PowerShell.
The certificate I'm trying to update is highlighted in the screenshot below (taken from certmgr.msc):
Here's the PowerShell code (largely taken from here):
Set-Location cert:
cd .\CurrentUser\Root
$cert = gci .\02FAF3E291435468607857694DF5E45B68851868
$cert.FriendlyName = "UserTrust CA"
(I've verified the thumbprint with the certificate properties in certmgr.msc to make sure it's the same certificate).
The last line will result in the following error:
Exception setting "FriendlyName": "Access is denied.
"
At line:1 char:7
+ $cert. <<<< FriendlyName = "UserTrust CA"
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
I've tried the following things so far:
Running PowerShell as administrator
Changing the execution policy using: Set-ExecutionPolicy Unrestricted
Other information:
PowerShell version is 2.0 (running on Windows 7 Enterprise x64)
I'm running the x64 version of PS
DEP and UAC are disabled
My account is part of the Administrators group
I'm a complete PowerShell n00b ;-)
PS version output:
$PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
2 0 -1 -1
You need to update your version of Powershell to 3.0 or 4.0.
See Get-ChildItem for Certificate
I have Powershell 4.0 and I was able to change the FriendlyName without problems. This was visible in certmgr.msc after a restart.
You can download Powershell 4.0 here.
If you are a Powershell beginner it's probably better to use Get-ChildItem instead of gci for improved readability. Also, cd is an alias of Set-Location so it's better to choose one or the other in your script to avoid confusion.
Description: I am running/executing powershell from a ruby script (.rb) file
exec "powershell.exe Import-Module PSWindowsUpdate"
I downloaded the PSWindowsUpdate module from "Windows Update PowerShell Module" and copied the files to the following location:
%WINDIR%\System32\WindowsPowerShell\v1.0\Modules
When I run the above I get the following error:
Z:\Desktop>ruby windows_patch.rb
Import-Module : The specified module 'PSWindowsUpdate' was not loaded because
no valid module file was found in any module directory.At line:1 char:1
+ Import-Module PSWindowsUpdate
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (PSWindowsUpdate:String) [I
mport-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Comm
ands.ImportModuleCommand
However, when I run this via Powershell it runs fine and dandy.
I'm using:
Windows 7 x64
PowerShell v4
Ruby v2.1.5
The result of exec "powershell.exe ruby -e 'puts $:'" is:
C:/Ruby21/lib/ruby/site_ruby/2.1.0
C:/Ruby21/lib/ruby/site_ruby/2.1.0/i386-msvcrt
C:/Ruby21/lib/ruby/site_ruby
C:/Ruby21/lib/ruby/vendor_ruby/2.1.0
C:/Ruby21/lib/ruby/vendor_ruby/2.1.0/i386-msvcrt
C:/Ruby21/lib/ruby/vendor_ruby
C:/Ruby21/lib/ruby/2.1.0
C:/Ruby21/lib/ruby/2.1.0/i386-mingw32
I ran powershell.exe $env:PSModulePath which gave me:
\vmware-host\Shared Folders\Documents\WindowsPowerShell\Modules;C:\Program Files (x86)\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\M
odules\
I then copied the folder to C:\Program Files (x86)\WindowsPowerShell\Modules
I then got:
Import-Module : The specified module 'PSWindowsUpdate' was not loaded because
no valid module file was found in any module directory.At line:1 char:39
Next, I then ran:
PS C:\Users\Justin.Schuhmann> Set-ExecutionPolicy -Scope LocalMachine
cmdlet Set-ExecutionPolicy at command pipeline position 1
Supply values for the following parameters:
ExecutionPolicy: Unrestricted
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
This solved the issue, I don't have a permanent solution yet as this is only temporary. When setting