When I try to deploy a project built in Visual Studio 2017 for SharePoint 2019 on Windows Server 2019 Standard Edition. I got the same error as above.
Apparently, VS 2017 uses WMI to control IIS during a redeploy. Without the features enabled, I got the same “Invalid namespace” error.
The solution was to: open the Turn Windows Features on or off menu in the Control Panel (under Programs), and enable WMI compatibility. The path to the feature is: