# define a format that is supported by our attribute $stringDate = '4/14 4:12PM' # try it first with the normal datetime type [datetime]'4/14 4:12PM' # this threw an error # define a variable that utilizes the attribute [datetime][DateTransform()]$dt = $stringDate # no error $dt # now let's add another format string utilizing the parameter of our custom attribute # note that the parameter accepts an array arguments. The argument(s) need to be always put in parenthesis for an array argument. [DateTransformAttribute(('xxx dd.MM hh:mm'))]$dt2 = 'xxx 15.12 10:45' $dt2