I'm wondering why the following code gives me the error: "ScriptMethod" is not recognized as the name of a cmdlet, function, script file, or operable program.
I look in the dotnet documentation for this field and it says:
-MemberType
Specifies the type of the member to add or change.
Use this parameter with the TypeName, MemberType, Value and SecondValue parameters to add or change a property or method of a type. The acceptable values for this parameter are:
AliasProperty
CodeMethod
CodeProperty
Noteproperty
ScriptMethod
ScriptProperty
For information about these values, see PSMemberTypes Enumeration.
Here's the code with the error:
$proto = @{
Force = $true
TypeName = "System.String"
MemberName = "RegexCount"
MemberType = ScriptMethod
Value = {
param([regex]$Regex)
$Regex.Matches($this).Count
}
}
Update-TypeData @proto