PowerShell from *nix user perspective

55
PowerShell from *nix user perspective Juraj Michálek – http://georgik.sinusgear.com 2. 10. 2013 EurOpen.CZ – Vranov nad Dyjí

description

Introduction to PowerShell from perspective of unix user. Some interesting tips for PoweShell users and pointers to open source resources.

Transcript of PowerShell from *nix user perspective

Page 1: PowerShell from *nix user perspective

PowerShell from *nix user perspective

Juraj Michálek – http://georgik.sinusgear.com2. 10. 2013EurOpen.CZ – Vranov nad Dyjí

Page 2: PowerShell from *nix user perspective

Examples @github

https://github.com/georgik/powershell-examples

Page 3: PowerShell from *nix user perspective

Where's the difference?

Page 4: PowerShell from *nix user perspective

Minimalistic approach?

After installing some Windows updates...

Page 5: PowerShell from *nix user perspective

Change font size

Page 6: PowerShell from *nix user perspective

Copy & paste text

Click & drag to select,Enter to copy to clipboard

Right click to paste

Page 7: PowerShell from *nix user perspective

Multi-line selection?

Page 8: PowerShell from *nix user perspective

PowerShell ISE

Page 9: PowerShell from *nix user perspective

ConEmu

http://code.google.com/p/conemu-maximus5/

Page 10: PowerShell from *nix user perspective

Text selection

Default: Shift+Click to mark and copy

Page 11: PowerShell from *nix user perspective

Zoom In/Out

CTRL + mouse wheelPowerShell ISEConEmu

Page 12: PowerShell from *nix user perspective

Commands from CMD.EXE works

Page 13: PowerShell from *nix user perspective

Unix like commands

Page 14: PowerShell from *nix user perspective

Cmdlets

Page 15: PowerShell from *nix user perspective

Get-Command

Page 16: PowerShell from *nix user perspective

Useful shortcuts

TAB – complete/expand/suggestShift+Tab – previous hint/suggestionCTRL+C – cancel current lineUp/Down – navigate in history

Page 17: PowerShell from *nix user perspective

Get-Help

Page 18: PowerShell from *nix user perspective

Get-Help -online

Page 19: PowerShell from *nix user perspective

Redirect output to file >

Note: output files are in unicode (double characters)

Page 20: PowerShell from *nix user perspective

Pipe |

Page 21: PowerShell from *nix user perspective

cd

Page 22: PowerShell from *nix user perspective

\\network\path

Page 23: PowerShell from *nix user perspective

Mathematics

Page 24: PowerShell from *nix user perspective

Variables

Page 25: PowerShell from *nix user perspective

Write-Host

Page 26: PowerShell from *nix user perspective

Output of cmdlet to variable

Page 27: PowerShell from *nix user perspective

Foreach

Page 28: PowerShell from *nix user perspective

Special variables

$_ - instance piped into command$? - true/false – success of last command$args – parameters for function$HOME – user's home$LASTEXITCODE – exit code of last process

Page 29: PowerShell from *nix user perspective

Compare

Page 30: PowerShell from *nix user perspective

For

` indicates that command will continue on next line

Page 31: PowerShell from *nix user perspective

*-Service

Page 32: PowerShell from *nix user perspective

Array [ ]

Page 33: PowerShell from *nix user perspective

Get-Member

E.g.: Get-Command calc | Get-Member(Get-Command calc).Path

Page 34: PowerShell from *nix user perspective

Select-String

Page 35: PowerShell from *nix user perspective

-whatif

Page 36: PowerShell from *nix user perspective

-confirm

Page 37: PowerShell from *nix user perspective

Get-ChildItem – find files

In case of long file path: | Select-Object -ExpandProperty FullName >file-list.txt

Page 38: PowerShell from *nix user perspective

Get-ChildItem registry

Page 39: PowerShell from *nix user perspective

Out-GridView

Page 40: PowerShell from *nix user perspective

Get-WmiObject

http://msdn.microsoft.com/en-us/library/windows/desktop/aa394084(v=vs.85).aspx

Page 41: PowerShell from *nix user perspective
Page 42: PowerShell from *nix user perspective

Stop and delete service

Page 43: PowerShell from *nix user perspective

Start-up configuration

~\Documents\WindowsPowerShell\ Microsoft.PowerShell_profile.ps1

Page 44: PowerShell from *nix user perspective

Execution policy

Page 45: PowerShell from *nix user perspective

Sample profile

Page 46: PowerShell from *nix user perspective

PowerShell Integrated Script Environment

Page 47: PowerShell from *nix user perspective

PowerShell 3 ISE

Page 48: PowerShell from *nix user perspective

ISE + .Net

F5 – Run script

Page 49: PowerShell from *nix user perspective

Run Selection

F8 – Run selection

Page 50: PowerShell from *nix user perspective

Debugging

F9 – Toggle break point

Page 51: PowerShell from *nix user perspective

Direct printer simulator

Page 52: PowerShell from *nix user perspective

PowerGUI

http://www.powergui.org

Page 53: PowerShell from *nix user perspective

Examples @github

https://github.com/georgik/powershell-examples

Page 54: PowerShell from *nix user perspective

Resources

PowerShell 3http://social.technet.microsoft.com/wiki/contents/articles/4725.powershell-v3-guide-en-us.aspx

PowerShell tipshttp://technet.microsoft.com/en-us/library/hh848797.aspx

Cheat Sheethttp://www.cheat-sheets.org/#WindowsPowerShell

PowerShell Bookshttp://powershellbooks.com/

Wikihttp://wiki.ysoft.local/display/RnD - How To PowerShell

Page 55: PowerShell from *nix user perspective

Juraj Michálek2. 10. 2013