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

Reset-Appx: Function Test-WinGetApp should use system context #10

Open
Skorfulose opened this issue Sep 18, 2023 · 4 comments · May be fixed by #11
Open

Reset-Appx: Function Test-WinGetApp should use system context #10

Skorfulose opened this issue Sep 18, 2023 · 4 comments · May be fixed by #11

Comments

@Skorfulose
Copy link

Hi Ben and all,

I am currently testing your superb script. My intent is to move some thousands existing systems with Company Portal user context installs to system context installs.
Maybe I am mistaken and get the script logic wrong. But I am wondering why the Test-WinGetApp function does not use the --scope machine parameter for its winget.exe calls? Without it, it defaults to the user scope. Which leads to an unnecessary call of the Install-WinGetApp function (with its explicit machine scope).

For me, when executing manually as SYSTEM (via psexec)...
...without explicit scope:

PS C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.20.2201.0_x64__8wekyb3d8bbwe> .\winget.exe list --id 9WZDNCRFJ3PZ --source msstore --accept-source-agreements
No installed package found matching input criteria.

...with explicit user scope:

PS C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.20.2201.0_x64__8wekyb3d8bbwe> .\winget.exe list --id 9WZDNCRFJ3PZ --source msstore --accept-source-agreements --scope user
No installed package found matching input criteria.

...with explicit machine scope:

PS C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.20.2201.0_x64__8wekyb3d8bbwe> .\winget.exe list --id 9WZDNCRFJ3PZ --source msstore --accept-source-agreements --scope machine
Name                    Id           Version
-----------------------------------------------
Microsoft.CompanyPortal 9WZDNCRFJ3PZ 11.2.179.0

My winget version:

.\winget.exe -v
v1.5.2201

It's an easy change to Test-WinGetApp. Just add the machine scope explicitly. Happy to submit a pull request if needed.

@byteben
Copy link
Owner

byteben commented Sep 20, 2023 via email

@Skorfulose
Copy link
Author

Yep, running the tests with psexec -i -s.

PS C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.20.2201.0_x64__8wekyb3d8bbwe> whoami
nt authority\system
PS C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.20.2201.0_x64__8wekyb3d8bbwe> .\winget.exe --version
v1.5.2201
PS C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.20.2201.0_x64__8wekyb3d8bbwe> .\winget.exe list --id 9WZDNCRFJ3PZ --source msstore --accept-source-agreements
No installed package found matching input criteria.
PS C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.20.2201.0_x64__8wekyb3d8bbwe> .\winget.exe list --id 9WZDNCRFJ3PZ --source msstore --accept-source-agreements --scope user
No installed package found matching input criteria.
PS C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.20.2201.0_x64__8wekyb3d8bbwe> .\winget.exe list --id 9WZDNCRFJ3PZ --source msstore --accept-source-agreements --scope machine
Name                    Id           Version
-----------------------------------------------
Microsoft.CompanyPortal 9WZDNCRFJ3PZ 11.2.179.0

@SamBlaettler
Copy link

I can confirm what Thomas reported a while ago, without the --scope machine switch the Company Portal is not recoginzed:
WingetList

@Skorfulose
Copy link
Author

I submitted my fix with PR #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants