The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, ...

The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, and EndProcessing methods, and only from that same thread. Validate that the cmdlet makes these calls correctly, or please contact Microsoft Support Services.