# Powershell ## Data storing ### Variable ```ps $x="Text" ``` ### Array ```ps $arry = @("a", "b", "c") ``` ## User Interaction ### Output #### Write-Host Also accepts from redirection ``` Write-Host [[-Object] ] [-NoNewline] [-Separator ] [-ForegroundColor ] [-BackgroundColor ] [] ``` ```ps Write-Host "text" ``` #### Write-Output ```ps Write-Output "text" ``` ## Filtering ```ps Write-Output "text" | Select-String -pattern $filters -notMatch ``` ## File interactions ### Read file ```ps Get-Contents $path ``` ### write to file ```ps Write-Host $text | Out-File $path ``` ## Operators ### Looping #### For #### For each ## Management ### Access remote PS server ```ps Enter-PSSession –ComputerName $hostname [-Credential username] ``` > If username gets left behind, the current user will be used # Hypver-V specific ## Management [//]: # (https://adamtheautomator.com/hyper-v-powershell/) ### Create new host New-VM -Name "HYPER" -MemoryStartupBytes 512MB ### List current VM Get-VM