Steps to reproduce
New-Module m {
class c {
[object] Invoke () { return Invoke-Something }
}
function Invoke-Something { 'Invoke-Something' }
function New-InstanceOfC { [c]::new() }
function Invoke-MethodOfC { (New-InstanceOfC).Invoke() }
Export-ModuleMember *OfC
} | Out-Null
(New-InstanceOfC).Invoke()
Invoke-MethodOfC
Expected behavior
I expected both calls to Invoke-Something to succeed and output
Invoke-Something
Invoke-Something
Actual behavior
Neither call to Invoke-Something succeeds.
Invoke-Something : The term 'Invoke-Something' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At C:\Users\un1\Desktop\test.ps1:3 char:37
+ [object] Invoke () { return Invoke-Something }
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-Something:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Invoke-Something : The term 'Invoke-Something' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At C:\Users\un1\Desktop\test.ps1:3 char:37
+ [object] Invoke () { return Invoke-Something }
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-Something:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-beta
PSEdition Core
GitCommitId v6.0.0-beta.6
OS Microsoft Windows 6.3.9600
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Steps to reproduce
Expected behavior
I expected both calls to
Invoke-Somethingto succeed and outputActual behavior
Neither call to
Invoke-Somethingsucceeds.Environment data