PowerTip: Find Other Ways to Use Split Method


Summary: Find other ways to use the Windows PowerShell Split method.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find if there are other ways to use the Split method from a String object?

Hey, Scripting Guy! Answer Use the PSMethod object that returns from the method when not calling it with parenthesis,
          and then call the OverLoadDefinitions property, for example:

PS C:> “string”.split.OverloadDefinitions

string[] Split(Params char[] separator)

string[] Split(char[] separator, int count)

string[] Split(char[] separator, System.StringSplitOptions options)

string[] Split(char[] separator, int count, System.StringSplitOptions options)

string[] Split(string[] separator, System.StringSplitOptions options)

string[] Split(string[] separator, int count, System.StringSplitOptions options)

Comments (6)

  1. jv says:

    [Enum]::GetNames([System.StringSplitOptions])

  2. Larry Weiss says:

    This is the great tip. Thanks!

  3. Larry Weiss says:

    Thanks jv for the tip about
    <#c:#> [Enum]::GetNames([System.StringSplitOptions])
    None
    RemoveEmptyEntries
    <#c:#>
    Are these [enum] values always composed of English words?

  4. Gerald H. says:

    That’s a good one! Thank you. I guess OverLoadDefinitions does work with other Methods as well?

Skip to main content