• TrimEnd accepts a char array, not a string. This is a more explicit way to write the code:

    [char[]]$charArray = @('_','D','a','t','a','.','m','d','f')

    "ccra_Data.mdf".TrimEnd($charArray) #1

    "ccrb_Data.mdf".TrimEnd($charArray) #2

    "Project_Data.mdf".TrimEnd($charArray) #3

    "Projecs_Data.mdf".TrimEnd($charArray) #4

    Notice the letters I bolded above are contained in the char array.

    String.TrimEnd Method

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato