You can create the class then do `[PwshProperty]::Id` to return `1`.
ParentContainsErrorRecordException: An error occurred while creating the pipeline.
Type : System.Management.Automation.RuntimeException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : An error occurred while creating the pipeline.
HResult : -2146233087
CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : RuntimeException
TargetSite :
Name : Invoke
DeclaringType : System.Management.Automation.Runspaces.PipelineBase, System.Management.Automation, Version=7.4.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
MemberType : Method
Module : System.Management.Automation.dll
Message : An error occurred while creating the pipeline.
InnerException :
Type : System.ArgumentException
Message : Method cannot be both static and virtual.
TargetSite : Void .ctor(System.String, System.Reflection.MethodAttributes, System.Reflection.CallingConventions, System.Type, System.Type[], System.Type[], System.Type[],
System.Type[][], System.Type[][], System.Reflection.Emit.RuntimeModuleBuilder, System.Reflection.Emit.RuntimeTypeBuilder)
Source : System.Private.CoreLib
HResult : -2147024809
StackTrace :
at System.Reflection.Emit.RuntimeMethodBuilder..ctor(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[]
returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][]
parameterTypeOptionalCustomModifiers, RuntimeModuleBuilder mod, RuntimeTypeBuilder type)
at System.Reflection.Emit.RuntimeTypeBuilder.DefineMethodCore(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[]
returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][]
parameterTypeOptionalCustomModifiers)
at System.Reflection.Emit.TypeBuilder.DefineMethod(String name, MethodAttributes attributes, Type returnType, Type[] parameterTypes)
at System.Management.Automation.Language.TypeDefiner.DefineTypeHelper.EmitPropertyIl(PropertyMemberAst propertyMemberAst, Type type)
at System.Management.Automation.Language.TypeDefiner.DefineTypeHelper.DefineProperty(PropertyMemberAst propertyMemberAst)
at System.Management.Automation.Language.TypeDefiner.DefineTypeHelper.DefineMembers()
at System.Management.Automation.Language.TypeDefiner.DefineTypes(Parser parser, Ast rootAst, TypeDefinitionAst[] typeDefinitions)
at System.Management.Automation.Language.Compiler.DefinePowerShellTypes(Ast rootForDefiningTypes, TypeDefinitionAst[] typeAsts)
at System.Management.Automation.Language.Compiler.GenerateTypesAndUsings(ScriptBlockAst rootForDefiningTypesAndUsings, List`1 exprs)
at System.Management.Automation.Language.Compiler.CompileSingleLambda(ReadOnlyCollection`1 statements, ReadOnlyCollection`1 traps, String funcName, IScriptExtent entryExtent,
IScriptExtent exitExtent, ScriptBlockAst rootForDefiningTypesAndUsings)
at System.Management.Automation.Language.Compiler.CompileNamedBlock(NamedBlockAst namedBlockAst, String funcName, ScriptBlockAst rootForDefiningTypes)
at System.Management.Automation.Language.Compiler.VisitScriptBlock(ScriptBlockAst scriptBlockAst)
at System.Management.Automation.Language.Compiler.Compile(CompiledScriptBlockData scriptBlock, Boolean optimize)
at System.Management.Automation.CompiledScriptBlockData.ReallyCompile(Boolean optimize)
at System.Management.Automation.CompiledScriptBlockData.CompileUnoptimized()
at System.Management.Automation.CompiledScriptBlockData.Compile(Boolean optimized)
at System.Management.Automation.DlrScriptCommandProcessor.Init()
at System.Management.Automation.DlrScriptCommandProcessor..ctor(ScriptBlock scriptBlock, ExecutionContext context, Boolean useNewScope, CommandOrigin origin,
SessionStateInternal sessionState, Object dollarUnderbar)
at System.Management.Automation.Runspaces.Command.CreateCommandProcessor(ExecutionContext executionContext, Boolean addToHistory, CommandOrigin origin)
at System.Management.Automation.Runspaces.LocalPipeline.CreatePipelineProcessor()
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options)
Prerequisites
Steps to reproduce
Run the following
Expected behavior
You can create the class then do `[PwshProperty]::Id` to return `1`.Actual behavior
ParentContainsErrorRecordException: An error occurred while creating the pipeline.Error details
Environment data
Visuals
No response