Last active
August 29, 2015 14:25
-
-
Save aggieben/a893acf7fcaaed565a47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is required | |
Import-Module pscx | |
# just drop this into your $profile, somewhere after the above import-module line | |
function With-Env ( | |
[string[]]$vars, | |
[Parameter(Position=1)] | |
[scriptblock]$f | |
) { | |
Push-EnvironmentBlock | |
Foreach ($var in $vars) | |
{ | |
$key,$val = $var -split "=",2 | |
Set-Item -Path "env:$key" -value $val | |
} | |
Invoke-Command -ScriptBlock $f | |
Pop-EnvironmentBlock | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment