Skip to content

v7.0.0-preview.1: can't cast string to [WMIClass] anymore #9780

@sba923

Description

@sba923

Steps to reproduce

Invoke the following:

[WMIClass] "\\$env:computerName\root\default:StdRegProv"

Expected behavior

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… {}

Actual behavior

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

Environment data

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions