vimwiki

PowerShell Basics

Basic CmdLets

Verb-Noun

Exemple:

Flags

Flag Do
-Verb  
-Nouns  

variable

create:

$my_variable = "hello"

Use:

$my_variable
hello

user imput:

$my_input = Read-Host -Prompt "enter a number"

Enforce type:

[Int]$age = 25

Create multiple variables:

$i = $j = $k = 0
$number, $color = 25, "red"

Method

$variable.GetType().Name

Arithmetic operators

Comparison operators

operator meaning
-eq equal
-ne not equal
-gt greater than
-lt lower than
-ge greater or equal
-le lower or equal
$my_num = 5
$my_num -ne 5
    False
7 -gt 2
    True

Logical operator