Skip to content

Commit

Permalink
Merge pull request #49 from benaph/patch-1
Browse files Browse the repository at this point in the history
Update PowerShell.md
  • Loading branch information
lwindolf authored Oct 18, 2023
2 parents 19ce5aa + 82abfcf commit 2c726de
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cheat-sheet/Windows/PowerShell.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Condition Examples

if ((-not [string]::IsNullOrEmpty($string)))
if (($nr > 5) -and ($string eq ''))
if ((-not [string]::IsNullOrEmpty($string))) { ... }
if (($nr -gt 5) -and ($string -eq '')) { ... }

## Control Flow

Expand All @@ -15,9 +15,9 @@
### Exceptions

try {
throw "My exception";
throw "My exception"
} catch {
Write-Output "Caught exception!";
Write-Output "Caught exception!"
}

## Functions
Expand All @@ -35,9 +35,9 @@

Fetching

$tmp = $env:SOME_ENV_VAR;
$tmp = $env:SOME_ENV_VAR

$env:Path = [Environment]::GetEnvironmentVariable('Path',[System.EnvironmentVariableTarget]::Machine);
$env:Path = [Environment]::GetEnvironmentVariable('Path',[System.EnvironmentVariableTarget]::Machine)

Setting env var on global level

Expand Down Expand Up @@ -70,8 +70,8 @@ Removing files/directories

## Download by URL

iwr -useb http://example.com/somefile
iwr -useb http://example.com/someexe | iex # Download and execute it
Invoke-WebRequest -useb http://example.com/somefile
Invoke-WebRequest -useb http://example.com/someexe | Invoke-Expression # Download and execute it

## Check PowerShell Version

Expand Down

0 comments on commit 2c726de

Please sign in to comment.