Some Powershell commands


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

1..14 writehost-foregroundcolor beijo

 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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: