powershell: (don't fear) the console
TRANSCRIPT
(Don't Fear) The Console Bruno Lopes
http://netponto.org24ª Reunião Presencial - 29/10/2011
Bruno Lopes
1980 1985 1990 1995 2000 2005 2010
Chart Title
Agenda
• What and how• Variables, loops, functions, pipelines, cmdlets• Gotchas and Tips• Extensibility• Extensions
Também disponível em vídeo...
Assista!http://www.youtube.com/watch?v=k2fL4etnvgA
Quem conhece…
bash ksh sed
ssh ls cat
awk vi perl
Console
Várias inspirações
• Javascript• Ruby• Perl• Bash
Feito para uso interactivo
• Case InSensiTive• Introspeção–get-member–get-help–get-command
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
Para quê?
Automatizar Prototipar
Explorar
Powershell
demonstração
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; } }}
Creating a pipeline function
function name {param($a)begin { # initialization }process { #work on param $a }end { # clean-up }
}
Outras hipoteses
• Modules• Providers
PSCX
• PowerShell Community Extensions–http://pscx.codeplex.com/
psake
https://github.com/JamesKovacs/psake
task Do-Stuff –depends Brilliant-Task `–description “Do stuff” {
Build-Solution Copy-Items bin\release package\output.zip}
Get-AudienceMembers ` | ? { $_.HaveQuestions()) ` | % { $speaker.Answer($_.GetQuestions())
Obrigado!
Bruno [email protected]://www.brunomlopes.comhttp://twitter.com/brunomlopes