Editing Environmental variables while using Postman CLI

@nategerman I assume you mean executing a collection by passing UUIDs for the environment? as follows:

postman collection run <collection-UUID> -e <environment-UUID>

In this instance, changes to environment will persist only for the duration of the collection run. If you want to persist changes past the run, you will need to use Postman’s APIs to update the environment.

Following can be used:

let apiKey = pm.environment.get('pm-api-key'); // Make sure to set your API key

// **Setup Request**
// See how we are passing the environment id and existing environment values
// pm.environment.id - will get the ID we set using `-e [UUID]`
// pm.environment.values - will return the array of variables current set 
updateEnvRequest = {
    url: 'https://api.getpostman.com/environments/' + pm.environment.id,
    method: 'PUT',
    header: {
        'Content-Type': 'application/json',
        'x-api-key': apiKey
    },
    body: {
        mode: 'raw',
        raw: JSON.stringify({
            environment: {
                values: pm.environment.values
            }
        })
    }
};

// Execute request to update the environment
pm.sendRequest(updateEnvRequest, (err, response) => {
    if(err) {
        console.log(err)
    } else {
        pm.test('Make sure environment updated passed', () => {
            pm.expect(response).to.have.property('code', 200);
            console.log('Environment updated!');
        });
    }
});