Open zippy1981 opened 12 years ago
it returns "does not appear to be on the source specified" if the $versionlatest is empty.
what happens when you just do a nuget list kdiff3 for example?
What is in the list.log in your chocolateyinstall folder after you run chocolatey update all?
nuget isn't on my path on the remote machine, but this is what I get if I execute C:\Chocolatey\chocolateyInstall\NuGet.exe list kdiff3 locally or remotely:
kdiff3 0.9.95
list.log should contain the output of all packages like you listed for kdiff. if that file doesn't have the information, you get the errors you see. lets first make sure it is resolving nuget before going into details.
go into C:\chocolatey\chocolateyinstall. type
. .\chocolatey.ps1
$nugetExe
does it return C:\Chocolatey\chocolateyInstall\nuget.exe ?
So it appears that much is working.
[myRemoteMachine]: PS C:\Users\jdearing\Documents> cd C:\chocolatey\chocolateyinstall
[myRemoteMachine]: PS C:\chocolatey\chocolateyinstall> . .\chocolatey.ps1
Please run chocolatey /? or chocolatey help
[myRemoteMachine]: PS C:\chocolatey\chocolateyinstall> $nugetExe
C:\chocolatey\chocolateyinstall\nuget.exe
[myRemoteMachine]: PS C:\chocolatey\chocolateyinstall>
didn't forget about this- i will test further, probably next week in my chocolatey lab. the issue is definitely $versionlatest being empty, but need to instrument it first hand.
I get inconsistent behavior from Chocolatey when using it in a remote session created using Enter-PSSession.
BUT if I use New-PSSession and then call Chocolatey with Invoke-Command, it works. Why? I have no idea... I'm new to PowerShell remoting. But given the inconsistent results from Chocolatey under Enter-PSSession, the "interactive" nature of the session seems likely to be the culprit.
Here's how I've gotten Chocolatey to work through a remote PowerShell session:
$securePassword = ConvertTo-SecureString "mypassword" -AsPlainText -force
$credential = New-Object System.Management.Automation.PsCredential("domain\login", $securePassword)
$session = New-PSSession -ComputerName server1 -Credential $credential
Invoke-Command -Session $session -Scriptblock { cinst 7zip }
# run other commands remotely using Invoke-Command... remove the session when done
Remove-PSSession $session
So what's the difference between Enter-PSSession and Invoke-Command -Session? Is it a matter of how stdin/stdout/stderr behave?
I ran into this problem when testing out chocolatey and here's how I solved it. The issue is really the infamous double-hop. Since nuget.exe is going to connect to remote system it will not be able to pass along NTLM credentials. However when I used CredSSP authentication and Invoke-Command
I was able to use all of the chocolatey commands (cup
, cinst
, etc.) remotely. This blog post has a good description of how to set up the CredSSP authetication mechanism.
@mzboray Thanks I tried your solution and it works for the most part. But I am still getting the "Your version is newer than the most recent. You must be smarter than the average bear..." error message when I run cver
I have been doing alot of experimentation lately around remoting and chocolate. My next boxstarter release will support this and auto configure the remoting client as well as the target as long as the wmi ports are open.
most packages will work fine using vanilla remoting but there are some tricky edge cases. One is the double hop scenario mentioned above. The solution there is using credssp. This will solve issues around accessing shares that require your auth token.
the stikiest issue is around windows update. Alot of Ms installs interact with the win update service. Examples are the .net frameworks, ie10, webpi and probably plenty others. Win update will not honor a remote token. The only reliable solution I have found is using scheduled tasks. I create a scheduled task for the choco pkg and forward the output and error streams to a file. I launch the task and use a file stream to stream to the console. Its more painful than I thought it would be.
one other case that simply won't work is most packages that use autoit or anything that interacts with a window.
not sure why there would be issues with enter-possession but I almost always use invoke-command.
@robianmcd I tried cver and it worked for me. I definitely saw that message a lot when I was trying to figure this out. That seems to be the error path when the output of nuget does not contain the package you are looking for (probably a bug that should be filed). I would take a look at C:\Chocolatey\chocolateyInstall\list.log to see what the output of nuget was on the remote machine.
@mzboray The list.log file just listed a bunch of packages but the chocolateyInstall.log outputs this when I run cver
:
[DEBUG] Running 'Chocolatey-Version' for chocolatey with source:''. [DEBUG] Running 'Get-ConfigValue' with configValue:'useNuGetForSources' [DEBUG] Running 'Get-UserConfigValue' with configValue:'useNuGetForSources' [DEBUG] After checking the user config the value of 'useNuGetForSources' is '' [DEBUG] Value not found in the user config file - checking the global config [DEBUG] Running 'Get-GlobalConfigValue' with configValue:'useNuGetForSources' [DEBUG] After checking the global config the value of 'useNuGetForSources' is 'false' [DEBUG] Running 'Get-UserConfigValue' with configValue:'sources' [DEBUG] Running 'Get-GlobalConfigValue' with configValue:'sources' [DEBUG] Using global sources [DEBUG] Using '-Source "http://chocolatey.org/api/v2/" -Source "https://go.microsoft.com/fwlink/?LinkID=230477 " ' as the source arguments [DEBUG] based on: '-Source "http://chocolatey.org/api/v2/" -Source "https://go.microsoft.com/fwlink/?LinkID=23 0477" ' feed [DEBUG] Calling 'C:\Chocolatey\chocolateyinstall\nuget.exe' list "chocolatey" -Source "http://chocolatey.org/a pi/v2/" -Source "https://go.microsoft.com/fwlink/?LinkID=230477" -NonInteractive [DEBUG] Long version of is '000000000000' [DEBUG] Long version of 0.9.8.20 is '000000000000.000000000009.000000000008.000000000020'
Any idea what's going on? Thanks!
@robianmcd As you might have guessed I have no idea what's wrong. list.log will have a bunch of packages, but it should have chocolatey in it. If it doesn't something is wrong with how nuget is getting the chocolatey package from its sources. Perhaps try pinging chocolatey.org (or using something like (new-object System.Net.WebClient).DownloadString("http://chocolatey.org/api/v2/")
) in the remote session and see if you can at least reach it.
@mzboray - the list.log file has all these chocolatey packages: chocolatey 0.9.8.20 ChocolateyPackageUpdater 0.6.1.0 ChocolateyDeploymentUtils 1.0.3 chocolatey.dev 1.0 ChocolateyGUI 0.11.1
Also running the command that pings chocolatey seems to work fine. I get this back:
`<?xml version="1.0" encoding="utf-8" standalone="yes"?>
`
I tried remoting into several computers and I get the error message on 3 of them (including my own computer). I get the expected results on another 3 computers and I get: "chocolatey does not appear to be on the source(s) specified" on the last computer?!? Note that the list.log file is empty on the last computer.
I've tried installing stuff with cinst and it seems to work fine though so maybe this isn't that big of a deal.
Thanks for your help!
I work on many SharePoint servers and created a PowerShell remoting "wrapper" to help automate tasks just like this. Basically, put your favorite PowerShell into the "verb" CSV and servers into the "noun" CSV and crank it up. HUGE time saver for me and I wanted to share with other PS remote admins. http://splaunch.codeplex.com/
If I remotely invoke powershell commands thrugh Enter-PSSession, running cup all or chocolatey update all gives the following:
However, if I RDP into the server and run powershell from the RDP session, it seems to work:
I should be able to run chocolatey through powershell remoting.