You're running update-wingetsoftware -all, but it looks like the function is failing with an "indexOf" method invocation error on a PSCustomObject. This likely means that the script or function update-wingetsoftware is trying to call .indexOf() on an object that doesn't support it (likely a PowerShell object, not a string or array).
1. Check what update-wingetsoftware is
update-wingetsoftware is not a built-in PowerShell command, so it's likely coming from one of your installed modules. Check where it's defined by running
Get-Command update-wingetsoftware -ErrorAction SilentlyContinue
- If it returns a path, the function is likely in a script file.
- If it returns a module name, you can inspect it using:
Get-Module -Name <module_name> | Select-Object -ExpandProperty Path
2. Check the function code
If update-wingetsoftware is a function, you can retrieve its definition:
Get-Content Function:\update-wingetsoftware
This will show you the code, allowing you to find where .indexOf() is being called incorrectly.
3. Manually upgrade winget apps As a workaround, try updating apps manually using:
winget upgrade --all
or, if you're using the WinGet PowerShell module:
Get-WinGetPackage -Upgrade | ForEach-Object { Start-WinGetPackageUpgrade -Id $_.Id }
4. Ensure your WinGet module is up to date
You have Microsoft.WinGet.Client version 1.10.340, but there might be a newer version. Update it using:
winget upgrade Microsoft.WinGet.Client
or reinstall:
winget install Microsoft.WinGet.Client
5. Check if another script is interfering
Since you have WinGet-Essentials (1.12.0) installed, the function might come from there. Try disabling that module and running update-wingetsoftware again:
Remove-Module WinGet-Essentials -Force
update-wingetsoftware -all
- If
update-wingetsoftwareis from a module, check for updates to that module:Update-Module <module_name> - If the error is in the script, replace
.indexOf()with.Contains()or another valid method for PowerShell objects.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin