powershell env with cmd - DmitrySemikin/dsemikin_notes GitHub Wiki
Set Environment Variables in Powershell using CMD script
This example is for setting environment variables for VisualC++
if (! (Test-Path "$env:VS140COMNTOOLS" -PathType Container) ) {
throw "Environment variable VS140COMNTOOLS not set or does not point to directory."
}
cmd.exe /c "call `"%VS140COMNTOOLS%\vsvars32.bat`" && call `"%VCINSTALLDIR%\vcvarsall.bat`" amd64 && set > `"%TEMP%\vcvars.txt`" "
Get-Content "$env:temp\vcvars.txt" | Foreach-Object {
if ($_ -match "^(.*?)=(.*)$") {
Set-Content "env:\$($matches[1])" $matches[2]
}
}