Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created function for Install-Winget #18

Merged
merged 3 commits into from
May 28, 2021

Conversation

RCShoemaker
Copy link
Contributor

No description provided.

@RCShoemaker
Copy link
Contributor Author

@tobraha I'm trying to figure out how to assign this to you...

@tobraha
Copy link
Contributor

tobraha commented May 27, 2021

image

@RCShoemaker
Copy link
Contributor Author

RCShoemaker commented May 27, 2021

I had to give you a role on the project before I could add you.
image

@tobraha
Copy link
Contributor

tobraha commented May 27, 2021

You should be able to just request a review from me instead of assigning the whole PR to me.

You would normally use 'Assignees' for issues rather than pull requests.

@RCShoemaker
Copy link
Contributor Author

Doesn't let me add you as a reviewer....

image

@RCShoemaker
Copy link
Contributor Author

But I can add you as an assignee after giving you triage access.
image

@RCShoemaker
Copy link
Contributor Author

@tobraha
Copy link
Contributor

tobraha commented May 28, 2021

Running some tests and received the following errors. Keep in mind that I did run our old decrapifier script on my Win10 VM before you fixed it.

PowerShell Core (7.1.3):

PS C:\Users\Tommy\repo\ATG-PS-Functions> install-winget
WinGet` is not installed. Installing the lasted from:
 https://github.com/microsoft/winget-cli/releases/download/v1.0.11451/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.appxbundle
Downloading Desktop App Installer
Add-AppxPackage:
Line |
 797 |          Add-AppxPackage -Path $LocalFilePath
     |          ~~~~~~~~~~~~~~~
     | The 'Add-AppxPackage' command was found in the module 'Appx', but the module could not be loaded. For more information, run 'Import-Module Appx'.

PowerShell (5.1.19041.906)

PS C:\users\Tommy\repo\ATG-PS-Functions> install-winget
WinGet is not installed. Installing the lasted from:
 https://github.com/microsoft/winget-cli/releases/download/v1.0.11451/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.appxbundle
Downloading Desktop App Installer
Add-AppxPackage : Deployment failed with HRESULT: 0x80073D19, An error occurred because a user was logged off.
Windows cannot install package Microsoft.DesktopAppInstaller_1.11.11451.0_x64__8wekyb3d8bbwe because this package
depends on a framework that could not be found. Provide the framework "Microsoft.VCLibs.140.00.UWPDesktop" published
by "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US", with neutral or x64 processor
architecture and minimum version 14.0.29231.0, along with this package to install. The frameworks with name
"Microsoft.VCLibs.140.00.UWPDesktop" currently installed
Windows cannot install package Microsoft.DesktopAppInstaller_1.11.11451.0_x64__8wekyb3d8bbwe because this package
depends on a framework that could not be found. Provide the framework "Microsoft.VCLibs.140.00.UWPDesktop" published
by "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US", with neutral or x64 processor
architecture and minimum version 14.0.29231.0, along with this package to install. The frameworks with name
"Microsoft.VCLibs.140.00.UWPDesktop" currently installed are:
{Microsoft.VCLibs.140.00.UWPDesktop_14.0.27810.0_x64__8wekyb3d8bbwe
Microsoft.VCLibs.140.00.UWPDesktop_14.0.27810.0_x86__8wekyb3d8bbwe
Microsoft.VCLibs.140.00.UWPDesktop_14.0.27629.0_x64__8wekyb3d8bbwe}
NOTE: For additional information, look for [ActivityId] c0354ce3-535b-0002-290f-36c05b53d701 in the Event Log or use
the command line Get-AppPackageLog -ActivityID c0354ce3-535b-0002-290f-36c05b53d701
At line:797 char:3
+         Add-AppxPackage -Path $LocalFilePath
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (C:\Users\admin\...bbwe.appxbundle:String) [Add-AppxPackage], Exception
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

Fiddled with this for a while until I finally tried manually downloading the appxbundle and double-clicking it, which then led to this prompt:

image

That installed "Microsoft Visual C++ 2015 UWP Desktop Runtime Package" from the store... and then Install-WinGet worked!

Also of note:

When running winget -v as Administrator (elevated prompt), you get:

PS C:\users\Tommy\repo\ATG-PS-Functions> winget -v
Program 'winget.exe' failed to run: The file cannot be accessed by the systemAt line:1 char:1
+ winget -v
+ ~~~~~~~~~.
At line:1 char:1
+ winget -v
+ ~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

So its invocation to see if it's already installed will fail if run as admin... Seems to be an known issue for recent releases of Windows 10 (reference: microsoft/winget-cli#637)

I'd say we can go ahead and merge this, but we'll need to keep that elevated privs issue in mind if we try to utilize this in any scripts.

Added dependency checks
Repaired PWSH install
@RCShoemaker
Copy link
Contributor Author

@tobraha
Try it now!!!
I added the check for the needed dependencies on older versions of Windows 10. As far as installing from PWSH goes, it's a non-starter. I worked it to run in normal PowerShell if it detects it's running in PWSH.

Only issue I'm seeing now is we can't work with appxpackages from our RMM agent, since it's running as system.
May need to create a temp account if we need work from backstage.
image

If (WGVersion -ne $WGVersion2) turned into If ($WGVersion -ne $WGVersion2)
@RCShoemaker RCShoemaker merged commit c20b15f into master May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants