jstubanas has a script up in the Massey Consulting forum for Setting GP CompanyID when copying data.
Massey Consulting – Setting GP CompanyID when copying data
Archived post from 2012. Dynamics GP and the links it points to have changed since; check current documentation before relying on version-specific steps.