Hi Ray,
You don't have to use any script. You can update the status using the Dynamics CRM Destination component.
You have to use the following values for statecode attribute (integer): 1 - Won, 2 - Lost
You can also optionally provide statuscode attribute (integer).
Regards,
Ivan