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