Helpful Powershell Commands
More samples at www.oreil.ly/poweshell-cookbook
Call a local exe
— use the call operator &
Set-Location $composefolder
& ‘C:\Program Files\docker\docker-compose.exe’ “up”
Call another PS script
Invoke-Expression “.\configure-system.ps1”
Show all env vars
Get-ChildItem Env:
Find a particular env variable
Get-ChildItem env: | ? {$_.name -eq ‘Path’} |Format-Table -wrap
Set Persistent Env var (persists after Powershell Session ends)
$CurrentValue = [Environment]::GetEnvironmentVariable(“Path”, “Machine”)
[Environment]::SetEnvironmentVariable(“Path”, $CurrentValue + “;$Env:ProgramFiles\docker”, “Machine”)
Set a Temporary Env Var (only valid for the Powershell session)
$env:PSModulePath = $env:PSModulePath + “;c:\ModulePath”
Leave a Reply