Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
PowerShell: Bringing DevOps to Windows
Kevin Berridge
August 19, 2016
Programming
0
140
PowerShell: Bringing DevOps to Windows
An introduction to the foundations and possibilities of PowerShell! As presented at Abstractions.io.
Kevin Berridge
August 19, 2016
Tweet
Share
More Decks by Kevin Berridge
See All by Kevin Berridge
kberridge
1
96
kberridge
3
540
kberridge
1
300
Other Decks in Programming
See All in Programming
yagitatsu
3
1.7k
hr01
1
1.3k
akatsukinewgrad
0
210
kubode
0
220
jrf
0
110
line_developers_tw2
0
800
viteinfinite
0
210
manfredsteyer
PRO
0
280
zsmb
2
110
sullis
0
120
line_developers_tw
0
1.4k
bkuhlmann
4
620
Featured
See All Featured
addyosmani
310
21k
matthewcrist
73
7.5k
bryan
100
11k
jonrohan
1021
380k
tammielis
237
23k
destraynor
223
47k
tenderlove
52
3.4k
lemiorhan
627
43k
deanohume
295
27k
paulrobertlloyd
71
1.4k
rocio
155
11k
notwaldorf
13
1.6k
Transcript
PowerShell: Bringing DevOps to Windows! Kevin Berridge @kberridge Matrix Pointe
Software
PowerShell
DevOps
Productivity
PowerShell
Foundation Possibilities
PowerShell: Bringing DevOps to Windows! Linux Mac
The Shell Scripting
The Shell
Basic Shell Commands and Aliases PowerShell Command PowerShell Alias DOS
Equivalent Unix Equivalent Set-Location sl cd* cd* Get-ChildItem gci dir* ls* Copy-Item cpi copy* cp* Move-Item mi move* mv* Remove-Item ri del* rm* Get-Content gc type* cat* Get-Help help help* man*
None
None
None
None
None
None
None
None
None
None
Summary • Aliases are nice because they are short, also
they match what you already know • Tab key auto completion is wonderful • The help command will teach you what you need to know
More Advanced Shell
Change .txt files to .ext files
ls *cmd*.txt | %{ mv $_ ($_.BaseName + ".ext" )
}
None
None
None
ls *cmd*.txt | %{ mv $_ ($_.BaseName + ".ext" )
}
None
ls *cmd*.txt | %{ mv $_ ($_.BaseName + ".ext" )
}
None
None
None
ls *cmd*.txt | %{ mv $_ ($_.BaseName + ".ext" )
}
Main Pipeline Commands • ForEach-Object (%) • Where-Object (?) •
Sort-Object (sort) • Select-Object (select)
None
None
How do we run a regular command line app?
None
What dlls did msbuild build?
None
Summary • Commandlets return objects • DOS command return strings
• “|” lets you easily chain commands together over those objects • Get-Member will tell you what those objects can do • %, ?, sort, select
Scripting
PSAKE
None
None
msbuild /v:m &”msbuild” /v:m iex ”msbuild /v:m”
None
None
None
None
None
PowerShell C# -eq == -ne != -gt > -ge >=
-lt < -le <= -like Regex -notlike -match -contains Linq
Summary • Scripts are no different than the shell! •
$variables • Use functions just like commandlets • Comparison operators • & and Invoke-Expression • $lastexitcode vs. exceptions • PSAKE: make for PowerShell
.NET
Store an encrypted string in an environment variable
Set-EncryptedEnvironmentVariable.ps1
None
Summary • PowerShell is a .NET language • You can
use anything in .NET from PowerShell
Possibilities
Collect log records and send a nightly email
None
None
None
Automate the execution of database migrations
migration-connections.xml
deploy-migrations.ps1
Honorable Mentions •PowerShell Remoting SSH for Windows! •PS Read Line
Better editing at the shell! •Set-PSBreakpoint Integrated debugging! •Desired State Configuration (DSC) Chef/Puppet for PowerShell!
PowerShell: Bringing DevOps to Windows! Kevin Berridge @kberridge Matrix Pointe
Software