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

Winget-Update-All problems running #48

Open
fdhin opened this issue Jul 11, 2023 · 2 comments
Open

Winget-Update-All problems running #48

fdhin opened this issue Jul 11, 2023 · 2 comments

Comments

@fdhin
Copy link

fdhin commented Jul 11, 2023

Running the Winget Update remediation script.

<#
Version: 1.0
Author: 
- Joey Verlinden (joeyverlinden.com)
- Andrew Taylor (andrewstaylor.com)
- Florian Slazmann (scloud.work)
- Jannik Reinhard (jannikreinhard.com)
Script: winget-upgrade-remediate.ps1
Description: Updates all apps via Winget
Hint: This is a community script. There is no guarantee for this. Please check thoroughly before running.
Version 1.0: Init
Run as: System
Context: 64 Bit
#> 

$Winget = Get-ChildItem -Path (Join-Path -Path (Join-Path -Path $env:ProgramFiles -ChildPath "WindowsApps") -ChildPath "Microsoft.DesktopAppInstaller*_x64*\AppInstallerCLI.exe")

&$winget upgrade --all --force --silent

However, it fails. I enabled script logging on a Windows 11 x64 Enterprise Edition and ran the script there. Output is below.
What could be the reason?

**********************
Windows PowerShell transcript start
Start time: 20230711185706
Username: WORKGROUP\SYSTEM
RunAs User: WORKGROUP\SYSTEM
Configuration Name: 
Machine: DESKTOP-TU33KA5 (Microsoft Windows NT 10.0.22621.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -executionPolicy bypass -file C:\WINDOWS\IMECache\HealthScripts\aa5e509b-0345-44ee-b489-64231866412e_5\remediate.ps1
Process ID: 31824
PSVersion: 5.1.22621.1778
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.22621.1778
BuildVersion: 10.0.22621.1778
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
**********************
Command start time: 20230711185706
**********************
PS>CommandInvocation(remediate.ps1): "remediate.ps1"
**********************
Windows PowerShell transcript start
Start time: 20230711185706
Username: WORKGROUP\SYSTEM
RunAs User: WORKGROUP\SYSTEM
Configuration Name: 
Machine: DESKTOP-TU33KA5 (Microsoft Windows NT 10.0.22621.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -executionPolicy bypass -file C:\WINDOWS\IMECache\HealthScripts\aa5e509b-0345-44ee-b489-64231866412e_5\remediate.ps1
Process ID: 31824
PSVersion: 5.1.22621.1778
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.22621.1778
BuildVersion: 10.0.22621.1778
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
**********************
Command start time: 20230711185707
**********************
PS>CommandInvocation(Out-String): "Out-String"
>> ParameterBinding(Out-String): name="InputObject"; value="The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object."
The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, 
a script block, or a CommandInfo object.
At C:\WINDOWS\IMECache\HealthScripts\aa5e509b-0345-44ee-b489-64231866412e_5\remediate.ps1:18 char:2
+ &$winget upgrade --all --force --silent
+  ~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression
The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, 
a script block, or a CommandInfo object.
At C:\WINDOWS\IMECache\HealthScripts\aa5e509b-0345-44ee-b489-64231866412e_5\remediate.ps1:18 char:2
+ &$winget upgrade --all --force --silent
+  ~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression
The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command
name, a script block, or a CommandInfo object.
At C:\WINDOWS\IMECache\HealthScripts\aa5e509b-0345-44ee-b489-64231866412e_5\remediate.ps1:18 char:2
+ &$winget upgrade --all --force --silent
+  ~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression

**********************
Command start time: 20230711185707
**********************
PS>$global:?
True
**********************
Windows PowerShell transcript end
End time: 20230711185707
**********************

@andrew-s-taylor
Copy link
Collaborator

It sounds like you don't have Winget installed at the system level

@duwady
Copy link

duwady commented Jul 28, 2023

I do have Winget installed in System mode mode but when I try to run the remediation script, I also get this error:

The expression after '&' in a pipeline element produced an object that was not valid. It must result
in a command name, a script block, or a CommandInfo object.
At C:\Users\mduwady\Cision\IntuneTest - Documents\Scripts\Remediations\winget-upgrade-remediate.ps1:18
char:3

  • & "$Winget" upgrade --all --force --silent
  • + CategoryInfo          : InvalidOperation: (:String) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression
    

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

No branches or pull requests

3 participants