asheroto / winget-install

Install winget tool using PowerShell! Prerequisites automatically installed. Works on Windows 10/11 and Server 2019/2022.
https://bit.ly/winget-install
GNU General Public License v3.0
272 stars 33 forks source link

[Bug]: current setup will not work inside winrm. #33

Closed ITJamie closed 9 months ago

ITJamie commented 10 months ago

Checklist

What You Are Seeing?

While winget will install with this script with winrm. it is not useable. any attempt to use winget via winrm will be unable to actually update source lists & unable to accept any source agreement.

someone documented an alternative method of setup here: https://github.com/microsoft/winget-cli/issues/256#issuecomment-1416929101

it would be nice if this method could be included in the winget-install script as an alternative install method flag for people wanting to use winget via winrm.

System Details

windows 2k22 server latest

issue detected when setting up an os with packer which uses winrm to manage the VM its building out

Additional Context

No response

Full Output With -DebugMode

due to the packer setup its quite difficult for me to get these logs as the build fails and the VM is deleted

asheroto commented 10 months ago

Hello,

any attempt to use winget via winrm will be unable to actually update source lists & unable to accept any source agreement.

Can you please provide a few examples/commands or screenshots?

Without the logs I'm not sure at what point the script fails. The script your provided is essentially what this script does at some point, it's similar but not quite the exact same.

Can you please try to get the script output? You can call the script and get the script output by doing this...

&([ScriptBlock]::Create((irm asheroto.com/winget))) -Force -DebugMode *> C:\winget-install.log

which will save the log to c:\winget-install.log in text format.

Or if you have the script locally you can just append *> c:\winget-install.log (space before the *) and it will output to that location as well.

ITJamie commented 10 months ago

Sorry just to clarify. The install script works and installs, however winget is currently not possible to run via winrm when it's installed in the standard layout. So while the install works its just not usable from winrm

The link above shows an alternate method of install that puts all of the winget requirements into a single directory which then allows winget to run and install packages from winrm.

So my request is to have a flag in the winget install script to install winget in the alternative fashion of having all the requirements in one folder and update the windows path.

asheroto commented 10 months ago

Ah I see. I'm trying to figure out what the difference is in the script. Maybe I can just add a line or two.

It looks like it operates the same as the script in the link you mentioned, but it does not do this...

cmd /c setx /M PATH "%PATH%;$ENV:PROGRAMFILES\WinGet"

Can you check on your winrm instance and see if winget is installed to that folder and this command corrects the issue after running this script?

I'm thinking maybe it's the setx because that changes the path.

asheroto commented 9 months ago

Hello,

We you able to fix the issue with that command?

If that fixes it, I can add it to the script pretty quick.

asheroto commented 9 months ago

I tried to reproduce the issue but was unable to. After running the installation command and then winget-install the installation succeeded. If you cannot use winget it may be due to an environmental setup. Try exiting winrm and then re-entering.

Closing the issue now but if you have more information I can re-open it.