Read and Write from the Interactive Shell

To write a value to the shell you can use the Write-Host command. It also allows you customize the console output.

$name = "Marius"
Write-Host -ForegroundColor White -BackgroundColor Black $name

To read a value from the interactive shell you can use Read-Host. This command will read a line of input from the console.

Write-Host "Please enter your age"
$age = Read-Host

Common cmdlets in Powershell

Here are some common used cmdlets in Powershell:

get-help

get-help process

– retrieves a list of commands available on a specific topic. For example, process

get-process

get-process

– returns information on processes

get-service

get-service

– returns information on the services that are installed on the computer

get-item

get-item C:\

– Gets the item at the specified location

get-content

get-content C:\file.txt

– returns the contents of the specified item