powershell: (don't fear) the console

20
(Don't Fear) The Console Bruno Lopes http://netpont o.org 24ª Reunião Presencial - 29/10/2011

Upload: comunidade-netponto

Post on 24-May-2015

2.426 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: PowerShell: (Don't Fear) The Console

(Don't Fear) The Console Bruno Lopes

http://netponto.org24ª Reunião Presencial - 29/10/2011

Page 2: PowerShell: (Don't Fear) The Console

Patrocinadores desta reunião

Page 3: PowerShell: (Don't Fear) The Console

Bruno Lopes

1980 1985 1990 1995 2000 2005 2010

Chart Title

Page 4: PowerShell: (Don't Fear) The Console

Agenda

• What and how• Variables, loops, functions, pipelines, cmdlets• Gotchas and Tips• Extensibility• Extensions

Page 6: PowerShell: (Don't Fear) The Console

Quem conhece…

bash ksh sed

ssh ls cat

awk vi perl

Page 7: PowerShell: (Don't Fear) The Console

Console

Page 8: PowerShell: (Don't Fear) The Console

Várias inspirações

• Javascript• Ruby• Perl• Bash

Page 9: PowerShell: (Don't Fear) The Console

Feito para uso interactivo

• Case InSensiTive• Introspeção–get-member–get-help–get-command

Page 10: PowerShell: (Don't Fear) The Console

Administração sem “espigas”

• Muitos servers têm bindings de powershell:– IIS–Sql Server–BizTalk–Sharepoint

• Se não tiver, finge-se:–Get-WmiObject–Cat <log> | Grep <pattern> | Do-Magic

Page 11: PowerShell: (Don't Fear) The Console

Para quê?

Automatizar Prototipar

Explorar

Page 12: PowerShell: (Don't Fear) The Console

Powershell

demonstração

Page 13: PowerShell: (Don't Fear) The Console

Create a cmdlet public class DbUpdateBase : PSCmdlet { protected override void ProcessRecord() {

// DO WORK }

[Parameter(Mandatory = false)] public string ConfigurationFile { get; set; }

[Parameter(Mandatory = true, Position = 0)] public string DeltasDirectory { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Defaults to mssql")] public string DatabaseType { get { return _databaseType; } set { _databaseType = value; } }}

Page 14: PowerShell: (Don't Fear) The Console

Creating a pipeline function

function name {param($a)begin { # initialization }process { #work on param $a }end { # clean-up }

}

Page 15: PowerShell: (Don't Fear) The Console

Outras hipoteses

• Modules• Providers

Page 16: PowerShell: (Don't Fear) The Console

PSCX

• PowerShell Community Extensions–http://pscx.codeplex.com/

Page 17: PowerShell: (Don't Fear) The Console

psake

https://github.com/JamesKovacs/psake

task Do-Stuff –depends Brilliant-Task `–description “Do stuff” {

Build-Solution Copy-Items bin\release package\output.zip}

Page 18: PowerShell: (Don't Fear) The Console

Get-AudienceMembers ` | ? { $_.HaveQuestions()) ` | % { $speaker.Answer($_.GetQuestions())

Page 19: PowerShell: (Don't Fear) The Console

Patrocinadores desta reunião

Page 20: PowerShell: (Don't Fear) The Console

Obrigado!

Bruno [email protected]://www.brunomlopes.comhttp://twitter.com/brunomlopes