This commit is contained in:
OriolFilter 2022-04-04 03:12:48 +02:00
parent 0aa358cac1
commit aeb411790f

View File

@ -13,6 +13,14 @@ $x="Text"
$arry = @("a", "b", "c")
```
### Hash Array
[MS documentation](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_hash_tables?view=powershell-7.2)
```
$X=@{ <name> = <value>; [<name> = <value> ] ...}
```
## User Interaction
### Output
@ -64,6 +72,14 @@ Write-Host $text | Out-File $path
## Operators
### Check if last command executed correctly
```ps
# Do something
echo $?
```
### Looping
#### For
@ -76,8 +92,13 @@ Write-Host $text | Out-File $path
Enter-PSSession ComputerName $hostname [-Credential username]
```
> If username gets left behind, the current user will be used
### Send command remotely
```ps
Invoke-Command -ComputerName hostname1, hostname2 -ScroptBlock {$COMMAND}
```
# Hypver-V specific
@ -85,7 +106,10 @@ Enter-PSSession ComputerName $hostname [-Credential username]
[//]: # (https://adamtheautomator.com/hyper-v-powershell/)
### Create new host
```ps
New-VM -Name "HYPER" -MemoryStartupBytes 512MB
```
### List current VM
Get-VM