Powershell cheatsheet

Sett UI språk til engelsk

Set-WinUILanguageOverride -Language en-US

Sluk output

. "C:\Source\Function.ps1" | Out-Null

Lag virtuelle partisjoner

Lager en path "D:" som kan nås i shellet, som peker på en mappe

New-Item -ItemType Directory C:\VirtualD -ErrorAction Ignore
New-Item -ItemType Directory C:\VirtualE -ErrorAction Ignore
New-Item -ItemType Directory C:\VirtualF -ErrorAction Ignore

subst.exe D: C:\VirtualD
subst.exe E: C:\VirtualE
subst.exe F: C:\VirtualF

$regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices"
Set-ItemProperty -Path $regPath -Name "D:" -Value "\??\C:\VirtualD"
Set-ItemProperty -Path $regPath -Name "E:" -Value "\??\C:\VirtualE"
Set-ItemProperty -Path $regPath -Name "F:" -Value "\??\C:\VirtualF"

Last inn nye ENV variabler

refreshenv

Les inn user input

$ACCESS_TOKEN = Read-Host "Paste Your Personal Access Token"

Pipe string inn til fil

"some text"
| Set-Content $Home/config.txt