wslutilities / wslu

A collection of utilities for Windows Subsystem for Linux
https://wslutiliti.es/wslu
GNU General Public License v3.0
3.44k stars 155 forks source link

wslfetch prints errors with powershell 7.3 #275

Closed tranzystorekk closed 1 year ago

tranzystorekk commented 1 year ago

Windows Version

Windows 11

Windows Build Number

22621.1555

WSL Version

WSL 2

Distro Version

Void Linux

WSL Utilities Version

4.1.1

Describe the bug

When running wslfetch, there are errors reported:

~
❯ wslfetch
gcim : Określona klasa nie istnieje.
At line:1 char:150
+ ... coding(852); [int64]((get-date) - (gcim Win32_OperatingSystem).LastBo ...
+                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (root\cimv2:Win32_OperatingSystem:String) [Get-CimInstance], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041010,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand

Cannot find an overload for "op_Subtraction" and the argument count: "2".
At line:1 char:128
+ ... oding(852); [int64]((get-date) - (gcim Win32_OperatingSystem).LastBoo ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

 /$$      /$$  /$$$$$$  /$$       Windows Subsystem for Linux (WSL2)
| $$  /$ | $$ /$$__  $$| $$       devuser@DESKTOP-0QOMDS0
| $$ /$$$| $$| $$  \__/| $$       Build: 22621
| $$/$$ $$ $$|  $$$$$$ | $$       Branch: ni_release
| $$$$_  $$$$ \____  $$| $$       Release: Void Linux
| $$$/ \  $$$ /$$  \ $$| $$       Kernel: Linux 5.15.90.1-microsoft-standard-WSL2
| $$/   \  $$|  $$$$$$/| $$$$$$$$ Uptime (Windows): 0d 0h 0m
|__/     \__/ \______/ |________/

Steps to Reproduce

Run wslfetch

Expected behavior

No errors, complete and valid fetch info is provided

Additional context

Verified with Powershell 7.3.3 and 7.3.4

Code of Conduct

tranzystorekk commented 1 year ago

Inspecting wslsys seems to point towards the get_windows_uptime() and get_win_system_type() functions failing on my system

patrick330602 commented 1 year ago

Can you try to type gcim Win32_OperatingSystem in your Powershell Core and post the result?

tranzystorekk commented 1 year ago
~
❯ gcim Win32_OperatingSystem
Get-CimInstance: Invalid class
patrick330602 commented 1 year ago

This seems to be a issue on your side: https://techcommunity.microsoft.com/t5/ask-the-performance-team/wmi-missing-or-failing-wmi-providers-or-invalid-wmi-class/ba-p/375485

this WMI class should exist on Windows

tranzystorekk commented 1 year ago

had some time to look at this, doing (in an elevated shell instance):

net stop winmgmt
winmgmt /resetrepository

worked for me

patrick330602 commented 1 year ago

I will include this in the F&Q for ref for people in the future