Skip to content

Instantly share code, notes, and snippets.

@bgshacklett
Created November 21, 2019 14:25
Show Gist options
  • Save bgshacklett/bff4f2a8e6caa89d9239735fe344cf21 to your computer and use it in GitHub Desktop.
Save bgshacklett/bff4f2a8e6caa89d9239735fe344cf21 to your computer and use it in GitHub Desktop.
A PowerShell Script/Function which takes a Posix environment (output by env, for instance) and converts it to a PowerShell environment format.
param
(
[Parameter(ValueFromPipeline="true")]
[String]$PosixVars
)
Process
{
$PosixVars `
| ForEach-Object {
$var = $_ `
-replace 'export ', '' `
-split '=' `
('$env:{0} = "{1}"') -f $var[0], $var[1]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment