Export-DMTransmittalsReport : Object reference not set to an instance of an object.

I'm running a script on a schedule to export a transmittal report from Deliverables Management. It sometimes fails with the following error: "Export-DMTransmittalsReport : Object reference not set to an instance of an object.".

The behaviour is not consistent, as on some runs - with no changes to the script - the export succeeds.

Any ideas what the issue might be?

I'm using PWDM connector for PWE 10.6.0.242 & PWDM_DAB 1.0.1.7 and this is the line returning the error:

Export-DMTransmittalsReport -ConnectedProjectId $id.ConnectedProjectId -ExportPath $ExportPath -IMSToken $token -TransmittalIds $transmittalIDs