Author Posts

February 16, 2017 at 4:33 pm

Hello,

I'm getting this message below, and I'm not sure what is causing the issue because I have another string that starts with "[UserColor]" and "[MembersOf-17]", both of which also have a "[", and it works fine.

The regular expression pattern [MembersOf-7] is not valid.
At \\hqfs1\Users\tantony\PowerShell\CalenderGroup\Calender.ps1:156 char:14
+ $Read_INI = $Read_INI -replace("$Items","$Replace")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ([MembersOf-7]:String) [], RuntimeException
+ FullyQualifiedErrorId : InvalidRegularExpression

Thank you,

Tony

February 16, 2017 at 4:47 pm

[ is a special character. You need to escape it as \[ if you mean to use it literally.

[UserColor] is being read as "any character that is U, s, e, r, C, o or l." In regex, [] represents a set or range.

February 16, 2017 at 4:51 pm

Thank you Don.

-cmatch "^\["

, I do have the escape on "["

I also found out that it will only happen if I delete the last "email" from a calendar group. Just need to figure out that now.

Thanks,