'"Invalid namespace" Error when trying to use NetQosPolicy in Powershell

Trying to limit the network bandwidth for a certain application, I came across such a thing as NetQosPolicy. I started trying to create new policies through PowerShell, but kept getting this error:

New-NetQosPolicy : New-NetQosPolicy : Invalid namespace string:1 character:1 + New-NetQosPolicy -Name TestPolicy -IPProtocolMatchCondition Both -Net ... + + CategoryInfo : MetadataError: (MSFT_NetQosPolicySettingData:ROOT/StandardCi...licySettingData) [New-Net QosPolicy], CimException + FullyQualifiedErrorId : HRESULT 0x8004100e,New-NetQosPolicy

I used this code: New-NetQosPolicy -Name TestPolicy -IPProtocolMatchCondition Both -NetworkProfile All -ThrottleRateActionBitsPerSecond 1200000

I thought I had made a mistake in the syntax and decided to look at the examples on the Microsoft website (https://docs.microsoft.com/en-us/powershell/module/netqos/new-netqospolicy?view=windowsserver2022-ps), but even their examples cause me the same error.

I haven't found a solution to this problem anywhere, so I'm asking on the forum. I will be grateful to anyone who knows how to solve this problem.

(By the way, I get the same error when I try to use the NetSecurity module (for example, the command: New-NetFirewallRule))



Solution 1:[1]

You might have a corrupt wmi repo, read this page but start with this check

Check if the repository is corrupted or not by running following command from command prompt with admin rights: winmgmt /verifyrepository

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mike Anthony