1..14 | % {write-host -foregroundcolor $_ “beijo”}
where 1..14 is the Range Operator – creates a array of numbers specified (in this example: 14)
% is the alias for each object
To print it out the array use {write-host -foreground $_ “beijo”}
Tip: Test with 15, then 16 or 17 and see what happens!
Result using the array of 14 numbers: a repetition of the word “beijo” (or “kiss” in Portuguese) 14 times
Some other commands:
get-process | stop-process -whatif
get-process | stop-process -confirm (asks to confirm each process that will stop)
Get-EventLog -LogName application -Newest 1
Get-verb – provides a list of all standard verbs
Get-Help
Get-Command -Verb get – lists all commands with verb Get
Get-Help Get-Process – Describes how to use the get-process (cheat sheet for the Get process command)
Get-Help Get-Process -Examples | more
Note: you can use CLI commands with PowerShell
Get-process powershell -fileversioninfo
========
Source: Windows PowerShell Scripting by Microsoft Scripting Guy Ed Wilson
