Invoke the following:
[WMIClass] "\\$env:computerName\root\default:StdRegProv"
Like in Windows PowerShell 5.1 and PowerShell 6.2.1, a ManagementClass object should be returned:
NameSpace: ROOT\default
Name Methods Properties
---- ------- ----------
StdRegProv {CreateKey, DeleteK… {}
Cannot convert value "\\SBAHOME\root\default:StdRegProv" to type "System.Management.ManagementClass". Error: "Cannot marshal 'parameter #3': Cannot marshal a string by-value with the [Out] attribute."
At line:1 char:1
+ [WMIClass] "\\$env:computerName\root\default:StdRegProv"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvalidCastToWMIClass
PS C:/Users/steph> $PSVersionTable
Name Value
---- -----
PSVersion 7.0.0-preview.1
PSEdition Core
GitCommitId 7.0.0-preview.1
OS Microsoft Windows 10.0.18362
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I can repo as:
[System.Management.ManagementClass]::new("test")
I guess it is .Net Core issue.
Tracking https://github.com/dotnet/corefx/issues/38093
@iSazonov what version of System.Management is PowerShell 7 referencing? If PowerShell updates the version of System.Management it ships with, then this exception should go away.
@jkoritzinsky It is 3.0.100-preview5-011568
https://github.com/PowerShell/PowerShell/blob/931c438ff1767cb53c3506c7a93a04d7b118df6e/global.json#L3
@SteveL-MSFT @daxian-dbw Should we close the issue or wait until we move to the new .Net preview version?
@iSazonov the System.Management DLL ships out of band (it’s not part of the SDK). It lives in its own NuGet package. You’re using an outdated version from before 3.0.0-preview3.
@jkoritzinsky Thanks for clarify!
Is https://www.nuget.org/packages/System.Management/4.6.0-preview5.19224.8 right version?
Yes that is the correct version.
Wouldn't Dependabot keep us up to date, or does that not automatically happen for major versions?
@SteveL-MSFT @daxian-dbw Do we ready to update all packages to new versions (from 4.5.* to 4.6.*)?
dependabot is configured to bump stable versions to newer stable versions, and pre-release versions to anything that is currently available. Since we have moved to target .NET Core 3.0 preview5, I think we should update the nuget references to the latest preview versions.
Ran into this as well. Importing the SCCM module hard crashes pwsh because they use that constructor in a finalizer.
they use that constructor in a finalizer.
Ooh, that's bad form!
:tada:This issue was addressed in #9888, which has now been successfully released as v7.0.0-preview.2.:tada:
Handy links:
Most helpful comment
Ooh, that's bad form!