I want to automatically add a header to every request in my whole collection using this pre-request script:
pm.request.headers.add({ \'key\': \"myvar\",
This certainly works. Loose the inverted commas on key and value
pm.request.headers.add({ key: "myvar", value: pm.environment.get("myvar") });