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\",
As of Postman v7.0.9, this is now possible by adding a Pre-request Script on a collection.
To do this, go to your collection, right-click it, select Edit, and go to the Pre-request Scripts tab, where you can add your snippet, i.e.:
Pre-request Scripts
pm.request.headers.add({ key: 'X-HEADER-TEST', value: '1' });