I think I'm just going to crawl under a rock and hide for a while.

It was that. I think I got mixed up when changing from checking @ERROR to saving the value in $ReturnCode.

I must have checked that bit of the script a dozen times.

Thanks

Mark