On a powershell session I tried to invoke some System.String
methods for string literals, but them failed
I Tried
"ssz"::EndsWith("z")
but it failed with this message error : Method invocation failed because [System.String] does not contain a method named 'EndsWith'.
Then I tried with another System.String
method
"ssz"::Substring(2,1)
but it failed too with error message Method invocation failed because [System.String] does not contain a method named 'Substring'.
To explore literal members I tried
"ssz"|Get-Member
and I got entries for EndsWith
and Substring
methods. This is the output. (I marked entries for my target methods)
I have .Net (c#) experience, and I read that powershell
is the best choice to use/consume code implemented in .Net custom assemblies from OS scripts without compiling .net code. I can't figure out where is my mistake or misconception. ¿Can anyone explaint me why my code fails?
Thank you
The OS is Windows Server 2019
PowerShell Version Info
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.2931
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.2931
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1