A collection of Powershell snippets I have found useful.
- Set the title of the window:
(Get-Host).UI.RawUI.WindowTitle = "New Window Title"
- Reload the path for the session (source):
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
- Delete all files/folders without confirmation messages:
rm -r -force .\path\to\dir
- List all environment variables with
Get-ChildItem
and its’ aliases:
Get-ChildItem Env:
gci Env:
dir Env:
ls Env:
- Get specific environment variable using the
Path
as an example. The first option returns just the value whereas the second returns it in a table format:
$Env:Path
gci Env:Path
- Set specific environment variable:
$env:Path = 'new value goes here'
$Env:Path = 'new value goes here'