<ext>[,<ext>]* is a comma separated list of extensions. The maximum length allowed for a single extension is 260 characters. Upto 255 extensions can be specified in a list.The include list determines if a given file should be screened. The exclude list determines if a given file should not be screened. If an extension is listed on both the exclude and the include list, files with that extension are not screened. If an extension is not listed on either the include list or the exclude list, files with that extension are not screened. The character ? is a wild card. When it is not the last character, it matches any single character. When it is the last character, or part of a trailing sequence of ? , it matches any number of characters (0, 1 or more).
This would suggest the theoretical maximum length of the combined list string of a number of file extensions is 66300 characters (255x260).
Errors out then $badExtensionList is over 255 characters. I have confirmed $badExtensionList is about 1800 characters long, with less than 255 individual elements. By going with man page description, this should be valid, but it does not work. Seems the cmdlet has a check for the total length of the string at 255 characters.
The reason behind me having such a long string is that I'm attempting to defend in depth against ransomware, which has a wide variety of known "bad" extensions.
The parameter accepts a string array, which PowerShell will automatically convert a comma separated list of values into an array...I'm wondering if PoSh has a length limit for string parameters. Have you tried passing an array of values instead of a comma separated list?
If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
As it turns out, I had a $null entry in the array, and this was what was preventing me from passing the array as input. Once I filtered out the $null element, I could pass the entire array.
However, there is a still a limitation of passing a string > 256 characters, but I'm not sure where this bug would lie. There is not such limitation in .NET as a whole or plain PowerShell, but that's more of an academic question at this point.
This also mean I can omit the step of joining the array to a string, as an added bonus.
Thanks for your help, I'm sure I will continue to post more problems as I stumble along.