Based on @mklement0's answer and with the same caveats, here's an in-memory solution that doesn't require serialization:
# Make a back-up of the environment variables
$env_bak = @(Get-ChildItem env:)
... my stuff ...
# Restore environment variables
Get-ChildItem env: | Remove-Item
$env_bak | % { Set-Item "env:$($_.Name)" $_.Value }
Operating on all of the environment variables seems like a risky proposition, so here's an alternative, filtering only those variables of interest:
# Make a back-up of selected environment variables
$env_bak_vars = @("MY_VAR", "THAT_THING", "PROJECT_DIR")
$env_bak = @(Get-ChildItem env: | Where-Object Name -CIn $env_bak_vars)
... my stuff ...
# Restore selected environment variables
Get-ChildItem env: | Where-Object Name -CIn $env_bak_vars | Remove-Item
$env_bak | % { Set-Item "env:$($_.Name)" $_.Value }