Following the steps to install Chocolatey via Powershell doesn't work on my Windows 7 64bit PC. I'm following https://chocolatey.org/install#install-from-powershell-v3
I have confirmed the ExecutionPolicy and that system path has
Powershell;
PS C:\Users\a> Get-ExecutionPolicy
AllSigned
PS C:\Users\a> ($env:Path).split(';')
%SystemRoot%\system32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files (x86)\Intel\iCLS Client\
C:\Program Files\Intel\iCLS Client\
C:\ProgramData\Oracle\Java\javapath
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files\Java\jre1.8.0_40\bin
C:\Program Files\Java\jdk1.8.0_40\bin
C:\Program Files (x86)\AMD\ATI.ACE\Core-Static
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files\Intel\Intel(R) Management Engine Components\IPT
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT
C:\HashiCorp\Vagrant\bin
C:\Program Files (x86)\Git\bin
C:\Program Files (x86)\Skype\Phone\
C:\Program Files (x86)\Git\bin
C:\Program Files (x86)\Git\libexec\git-core
C:\Program Files (x86)\Nmap
C:\Program Files\smartmontools\bin
Here are my error messages;
PS C:\Users\a> iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
???# : The term '???#' 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
+ ???# =====================================================================
+ ~~~~
+ CategoryInfo : ObjectNotFound: (???#:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.5.
!Test-Path : The term '!Test-Path' 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:188 char:11
+ } elseif (!Test-Path $7zaExe) {
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (!Test-Path:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Extracting C:\Users\a\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\a\AppData\Local\Temp\chocolatey\chocInstall...
Exception calling "Start" with "0" argument(s): "The system cannot find the file specified"
At line:211 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 line:212 char:3
+ $process.BeginOutputReadLine()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
Exception calling "WaitForExit" with "0" argument(s): "No process is associated with this object."
At line:213 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 line:225 char:15
+ default { throw "$errorMessage 7-Zip signalled an unknown error (code $exitC ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Unable to unzip...n error (code ):String) [], RuntimeException
+ FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install again. Error: 7-Zip signalled an unknown error (code )
I have tried the error messages suggestion on the last line
Perhaps try setting $env:chocolateyUseWindowsCompression = 'true'
But that only results in a whole series of other errors
PS C:\admin\scripts> iwr https://chocolatey.org/install.ps1 -UseBasicParsing
StatusCode : 200
StatusDescription : OK
Content : # =====================================================================
...
You're downloading a UTF-8-encoded file (the content begins with the characteristic UTF-8 byte order mark ), but it's being treated as ASCII text.
Besides:
I'm following https://chocolatey.org/install#install-from-powershell-v3.
No, you're not. The website you referenced tells you to use
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
which works as advertised, whereas you're trying to use
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
If you want to use that approach you need to remove the BOM from the content before piping it into Invoke-Expression:
(iwr https://chocolatey.org/install.ps1 -UseBasicParsing).Content -replace '^' | iex
Related
I was going to automate some regular task on client computers using Powershell module. In this way, PSWINDOWSUPDATE is one of bests. But, I receive an error during install that:
PS C:\Users\stackoverflow> install-module -name pswindowsupdate -scope currentuser
PackageManagement\Install-Package : Package 'PSWindowsUpdate' failed to be installed because:
Access to the path 'C:\Users\stackoverflow\AppData\Local\Temp\ipufiq2h\PSWindowsUpdate.dll' is denied.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ... $null = PackageManagement\Install-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (PSWindowsUpdate:String) [Install-Package], Exception
+ FullyQualifiedErrorId : Package '{0}' failed to be installed because: {1},Microsoft.PowerShell.PackageManagement
.Cmdlets.InstallPackage
running the command in administrative mode and without -scope switch didn't solve the problem.
Edit1: The problem is solved. But there is another problem. When I call import-module pswindowsupdate following error occurs:
import-module : Errors occurred while loading the format data file:
C:\Users\stackoverflow\Documents\WindowsPowerShell\Modules\pswindowsupdate\2.2.0.2\PSWindowsUpdate.Format.ps1xml, ,
C:\Users\stackoverflow\Documents\WindowsPowerShell\Modules\pswindowsupdate\2.2.0.2\PSWindowsUpdate.Format.ps1xml: The file was skipped because of the following validation exception: File
C:\Users\stackoverflow\Documents\WindowsPowerShell\Modules\pswindowsupdate\2.2.0.2\PSWindowsUpdate.Format.ps1xml 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
+ import-module pswindowsupdate
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], RuntimeException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Use Get-ExecutionPolicy to set it e.g. to RemoteSigned:
Get-ExecutionPolicy -List
Set-ExecutionPolicy RemoteSigned
also see here
Hi Guys, I'm trying to modify this PowerShell script and put it in windows startup. So every restart a VBScript will call this PowerShell script and it will update the info like a Windows Sysinternals BGinfo.
https://pastebin.com/nDh2L9dm
# Close Graphics
$image.Dispose();
# Save and close Bitmap
$background.Save($out, [system.drawing.imaging.imageformat]::Png);
$background.Dispose();
$bmp.Dispose();
# Output file
Get-Item -Path $out
This is the error I get in PowerShell ISE
Exception calling "Save" with "2" argument(s): "A generic error occurred in GDI+."
At D:\Desktop\PS-BGInfo-My-Version.ps1:195 char:5
+ $background.Save($out, [system.drawing.imaging.imageformat]::Png) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ExternalException
I am working on Windows 2012 R2 and it was running PowerShell version 4.0. I have upgraded to version 5.0.
It seems like that when I do basic commands I get errors, for example,
PS C:\Windows\system32> Install-Module –Name PowerShellGet –Force –Verbose
Install-Module : The 'Install-Module' command was found in the module
'PowerShellGet', but the module could not be loaded. For more
information, run 'Import-Module PowerShellGet'. At line:1 char:1
+ Install-Module –Name PowerShellGet –Force –Verbose
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
Another example:
PS C:\Windows\system32> import-module PowerShellGet
Get-Variable : The term 'Get-Variable' 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 C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\1.1.3.2\PSModule.psm1:18
char:28
+ $script:IsWindows = (-not (Get-Variable -Name IsWindows -ErrorAction ...
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Variable:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I am basically following the installation method for PowerShellGet found here: https://learn.microsoft.com/en-us/powershell/gallery/psget/get_psget_module
I am stuck at the "Install-Module" command in this guide.
Execute the command on your powershell: 'Set-ExecutionPolicy Unrestricted' before executing install-module.
(The restricted mode helps you protect from the the unauthorized scripts)
I know I too late to answer this question. But may help to others.
Try following ,
Set-ExecutionPolicy Unrestricted
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
and now you can try install-module
This didn't work for me
PS C:\temp> Set-PSRepository -NAME PSGallery -InstallationPolicy Trusted
PackageManagement\Get-PackageProvider : The term 'PackageManagement\Get-PackageProvider' 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 C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:2934 char:26
... $nugetProvider = PackageManagement\Get-PackageProvider -ErrorA ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
PackageManagement\Get-PackageProvider : The term 'PackageManagement\Get-PackageProvider' 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 C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:2948 char:40
... ailableNugetProviders = PackageManagement\Get-PackageProvider -Name $ ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
PackageManagement\Install-PackageProvider : The term 'PackageManagement\Install-PackageProvider' 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 C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:3138 char:21
$null = PackageManagement\Install-PackageProvider -Name $ ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (PackageManageme...PackageProvider:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
PackageManagement\Import-PackageProvider : The term 'PackageManagement\Import-PackageProvider' 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 C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:3144 char:21
$null = PackageManagement\Import-PackageProvider -Name $s ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (PackageManagement\Import-PackageProvider:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
PackageManagement\Get-PackageProvider : The term 'PackageManagement\Get-PackageProvider' 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 C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:3148 char:30
... $nugetProvider = PackageManagement\Get-PackageProvider -Name $ ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
Set-PSRepository : NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201' or newer version of NuGet provider is installed.
At line:1 char:1
Set-PSRepository -NAME PSGallery -InstallationPolicy Trusted
+ CategoryInfo : InvalidOperation: (:) [Set-PSRepository], InvalidOperationException
+ FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Set-PSRepository
PS C:\temp>
I have downloaded and installed the Azure Powershell by following the MS instructions:
https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/
Using the Windows Powershell ISE I run the command:
Login-AzureRmAccount
which returns the the error:
Login-AzureRmAccount : The 'Login-AzureRmAccount' command was found in the module 'AzureRM.Profile', but the module could not be loaded. For more information, run 'Import-Module AzureRM.Profile'. At line:1 char:1
+ Login-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Login-AzureRmAccount:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
Import-Module AzureRM.Profile
Returns this error:
Import-Module : File C:\Program Files (x86)\Microsoft
SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Profile\CheckVersions.ps1 cannot be loaded
because running scripts is disabled on this system. For more information, see about_Execution_Policies at
http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ Import-Module AzureRM.Profile
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [Import-Module], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
Why is it so difficult to connect to Azure, what could be wrong?
From the command prompt run:
powershell Set-ExecutionPolicy RemoteSigned
I have several steps to figure out this problem and I do't know what else to do. My end goal is to check my "app.exe" file version. when I run it on server manually both script versions work. But when Octopus runs both versions fail with different errors
Version 1:
$file = "C:\Octopus\Applications\AppStartUp\38.2.19.0\app.exe"
$fileVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($file).FileVersion
I get the error:
return [System.Diagnostics.FileVersionInfo]::GetVersionInfo <<<< ($file). FileVersion
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : DotNetMethodException
Version 2:
$file = "C:\Octopus\Applications\AppStartUp\38.2.19.0\app.exe"
(Get-Command "$file").FileVersionInfo.Fileversion
Error Message
Export-ModuleMember : The Export-ModuleMember cmdlet can only be called from in side a module. At C:\Octopus\Applications\CSIS_DEV\ESG.CSIS.StartUp\38.2.19.0\deployment\clickOnceLib.ps1:35 char:20
+ Export-ModuleMember <<<< -function * -alias *
+ CategoryInfo : PermissionDenied: (:) [Export-ModuleMember], InvalidOperationException
+ FullyQualifiedErrorId : Modules_CanOnlyExecuteExportModuleMemberInsideAModule,Microsoft.PowerShell.Commands.ExportModuleMemberCommand
Get-Command : The term 'C:\Octopus\Applications\CSIS_DEV\ESG.CSIS.StartUp\38.2.19.0\ESG.CSIS.StartUp.exe' 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 C:\Octopus\Applications\CSIS_DEV\ESG.CSIS.StartUp\38.2.19.0\deployment\clickOnceLib.ps1:32 char:24
+ return (Get-Command <<<< "$file").FileVersionInfo.Fileversion
+ CategoryInfo : ObjectNotFound: (C:\Octopus\Appl...SIS.StartUp.exe:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
Any Insite to these messages and why it happens only when running in octopus would be great.
It looks like your script can't access the file, or it doesn't exist. Check to make sure C:\Octopus\Applications\CSIS_DEV\ESG.CSIS.StartUp\38.2.19.0\ESG.CSIS.StartUp.exe exists and is accessible to the user the tentacle runs under (use windows effective permissions).
Also make sure it's there by the time the script runs, you haven't mentioned whether this is a seperate step, PreDeploy.ps1, Deploy.ps1 or PostDeploy.ps1 script