Steps to reproduce
$ps = $ps2 = $null
try {
$ps = [powershell]::Create('CurrentRunspace')
$cmdlet = [System.Management.Automation.CmdletInfo]::new('un-resolvable', [Microsoft.PowerShell.Commands.FormatDefaultCommand])
$null = $ps.AddCommand($cmdlet).AddParameter("InputObject", 'test')
$ps2 = [powershell]::Create('CurrentRunspace')
# Setter for "Commands" calls PSCommand.Clone()
$ps2.Commands = $ps.Commands
$ps.Invoke()
$ps2.Invoke()
} finally {
if ($null -ne $ps2) {
$ps2.Dispose()
}
if ($null -ne $ps) {
$ps.Dispose()
}
}
Expected behavior
Actual behavior
test
MethodInvocationException:
Line |
13 | $ps2.Invoke()
| ~~~~~~~~~~~~~
| Exception calling "Invoke" with "0" argument(s): "The term 'un-resolvable' 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."
Environment data
Name Value
---- -----
PSVersion 7.1.0-preview.1
PSEdition Core
GitCommitId 7.1.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
Fix
The clone constructor for SMAR.Command doesn't copy the value of the CommandInfo property from the command to be cloned.
/cc @TylerLeonhardt
Steps to reproduce
Expected behavior
Actual behavior
Environment data
Fix
The clone constructor for
SMAR.Commanddoesn't copy the value of theCommandInfoproperty from the command to be cloned./cc @TylerLeonhardt