Gavin Barron, Solution Architect
March 22, 2014
ComCamp Auckland
PowerShell:
Automation for
Everyone
The only five commands you need
Rules for writing scripts
Demos
Intro
Wrap up
Our agenda
PowerShell: Automation for Everyone | 3
 SharePoint Server MVP
 Developer
 Skier
 http://gavinb.net
 @gavinbarron
 gavin.barron@intergen.co.nz
Gavin Barron
Solution Architect
Your presenter
PowerShell: Automation for Everyone | 4
Why Automate?
 Repeatability
 Reliability
 Save time?
 Eliminate boring manual tasks
PowerShell: Automation for Everyone | 5
Why PowerShell?
 Product specific cmdlets
 Able to run .NET code
 Hooks into WMI/COM
 Object pipeline
 Readable scripts
The only five
commands you need
Your Awesome Presentation Title {Segoe UI 12 pt.}
Get-Command
Your Awesome Presentation Title {Segoe UI 12 pt.}
Get-Help
Your Awesome Presentation Title {Segoe UI 12 pt.}
Get-Member
Your Awesome Presentation Title {Segoe UI 12 pt.}
Where-Object
Your Awesome Presentation Title {Segoe UI 12 pt.}
ForEach-Object
Demos
Your Awesome Presentation Title {Segoe UI 12 pt.}
Find the command
you need
Your Awesome Presentation Title {Segoe UI 12 pt.}
Simple Pipeline Use
PowerShell: Automation for Everyone | 15
File renaming in .bat
@echo off
for /f "delims=" %%a in ('dir /b *.txt') do call :dot "%%a"
pause
goto :EOF
:dot
set "var=%~n1"
set "var=%var:.=_%"
echo ren %1 "%var%%~x1"
Rules for writing
scripts
PowerShell: Automation for Everyone | 17
Consider error cases
 What should you do when it goes pear shaped?
 Default behaviour is Ignore and Continue
 $ErrorActionPreference
 -ErrorAction
 try{} catch{}
PowerShell: Automation for Everyone | 18
Consider your outputs
 Write-Host
 Write-Output
 Write-Progress
 Add-Content
 Out-File
PowerShell: Automation for Everyone | 19
Have style!
 Use a coding convention
 Naming
 Casing
 Bracing
 Avoid aliases
 Be Consistent!
PowerShell: Automation for Everyone | 20
Leverage functions for re-use
 Small tasks
 Compose a script from functions
 Functions are highly reusable
 Cmdlet Binding Attribute
 Parameters Attribute
 Default Values
PowerShell: Automation for Everyone | 21
Use configuration files
$file =[xml] (Get-ChildItem $constantsFilePath)
$root = "setup-config"
$ConstantsNodeList = $file.$root.Constants
foreach($property in $ConstantsNodeList.Property) {
$key= $property.Key
$value=$property.Value
$webApp.Properties.Add($key,$value)
}
$webApp.Update()
Your Awesome Presentation Title {Segoe UI 12 pt.}
Script Examples
Wrap up
Your Awesome Presentation Title {Segoe UI 12 pt.}
Start scripting, it’s easy!
PowerShell: Automation for Everyone | 25
Handy resources
 http://blogs.technet.com/b/heyscriptingguy
 http://gallery.technet.microsoft.com/scriptcenter
 http://social.technet.microsoft.com/Forums/scriptcenter/en-
US/home?forum=ITCG
 http://ss64.com/ps/
 http://ss64.com/ps/syntax.html
Any questions?
Email: gavin.barron@intergen.co.nz
Blog: http://gavinb.net
Twitter: @gavinbarron
Thank you
PowerShell: Automation for everyone

More Related Content

PDF
Slim PHP when you don't need the kitchen sink
PDF
Continuous delivery in AWS
PPTX
Alfresco Development Framework Basic
PDF
Modern infrastructure as code with ansible cake fest 2021
PPTX
North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...
PPTX
State in stateless serverless functions
PPTX
AWS CodeDeploy - basic intro
PDF
Build a bot workshop async primer - php[tek]
Slim PHP when you don't need the kitchen sink
Continuous delivery in AWS
Alfresco Development Framework Basic
Modern infrastructure as code with ansible cake fest 2021
North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...
State in stateless serverless functions
AWS CodeDeploy - basic intro
Build a bot workshop async primer - php[tek]

What's hot (19)

PDF
Do things faster and better with WebAssembly - Sendil Kumar Nellaiyapen - Cod...
PDF
Modern infrastructure as code with ansible PyTN
PDF
Writing your First Ansible Playbook
PPTX
Why I am hooked on the future of React
PDF
SPA Flask Vue
PDF
Ansible Introduction
PPT
Streamlined Geek Talk
PPTX
Don't roll your own HTTP server
PPTX
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
PPTX
Selenium – Web Browser Automation
PPTX
“ASP.NET Core. Features and architecture”
PPTX
API Test Automation Using Karate (Anil Kumar Moka)
PPTX
Save time, save money: Move your selenium testing on cloud
PDF
Async/Await: TPL & Message Pumps
PDF
API Design in the Modern Era - Architecture Next 2020
PDF
Route service-pcf-techmeetup
PDF
Keep your projects up-to-date
PDF
Async/Await Best Practices
PDF
HTBYOOFIYRHT RubyConf
Do things faster and better with WebAssembly - Sendil Kumar Nellaiyapen - Cod...
Modern infrastructure as code with ansible PyTN
Writing your First Ansible Playbook
Why I am hooked on the future of React
SPA Flask Vue
Ansible Introduction
Streamlined Geek Talk
Don't roll your own HTTP server
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
Selenium – Web Browser Automation
“ASP.NET Core. Features and architecture”
API Test Automation Using Karate (Anil Kumar Moka)
Save time, save money: Move your selenium testing on cloud
Async/Await: TPL & Message Pumps
API Design in the Modern Era - Architecture Next 2020
Route service-pcf-techmeetup
Keep your projects up-to-date
Async/Await Best Practices
HTBYOOFIYRHT RubyConf
Ad

Viewers also liked (15)

PPTX
ЮУРГУ Интернет ресурсы историка
PPTX
IoT with SignalR & .NET Gadgeteer - NetMF@Work
PDF
UI design for Mobile
PPTX
.NET MF & Gadgeteer - Real Cases - NetMF@Work
PDF
My Resume
PPTX
интернет для историков – важнейшие информационные сайты
PDF
Kleider foto-gallery
PPTX
Affording Study Abroad
DOCX
บทความเด็กแว้น
PDF
Visual Resume by Olivier Tisun
PPSX
G-TEC Presentation
PPS
Narmer American College In A Glance
PPT
хімічні волокна
PDF
PDF
El delito de violencia y resistencia contra un policía
ЮУРГУ Интернет ресурсы историка
IoT with SignalR & .NET Gadgeteer - NetMF@Work
UI design for Mobile
.NET MF & Gadgeteer - Real Cases - NetMF@Work
My Resume
интернет для историков – важнейшие информационные сайты
Kleider foto-gallery
Affording Study Abroad
บทความเด็กแว้น
Visual Resume by Olivier Tisun
G-TEC Presentation
Narmer American College In A Glance
хімічні волокна
El delito de violencia y resistencia contra un policía
Ad

Similar to PowerShell: Automation for everyone (20)

PPTX
Introduction to windows power shell in sharepoint 2010
PPS
Simplify your professional web development with symfony
PPTX
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
PPTX
Automating PowerShell with SharePoint
PPTX
Power shell training
PDF
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
PPTX
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
PPTX
PowerShell-1
PDF
Introduction to PowerShell
PDF
Revoke-Obfuscation
PPTX
Intro to PowerShell Workflow
PPTX
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
PPTX
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
PDF
Real world Webapp
PDF
Django Introduction & Tutorial
PDF
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
PDF
Automating Your Enterprise Application Deployments with PowerShell
PDF
All the Laravel things: up and running to making $$
PDF
Easy native wrappers with SWIG
PPTX
Wsv406 Advanced Automation Using Windows Power Shell2.0
Introduction to windows power shell in sharepoint 2010
Simplify your professional web development with symfony
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
Automating PowerShell with SharePoint
Power shell training
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
PowerShell-1
Introduction to PowerShell
Revoke-Obfuscation
Intro to PowerShell Workflow
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Real world Webapp
Django Introduction & Tutorial
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
Automating Your Enterprise Application Deployments with PowerShell
All the Laravel things: up and running to making $$
Easy native wrappers with SWIG
Wsv406 Advanced Automation Using Windows Power Shell2.0

Recently uploaded (20)

PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
DOCX
search engine optimization ppt fir known well about this
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
CloudStack 4.21: First Look Webinar slides
PPTX
The various Industrial Revolutions .pptx
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Hybrid model detection and classification of lung cancer
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
Modernising the Digital Integration Hub
PDF
STKI Israel Market Study 2025 version august
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
Tartificialntelligence_presentation.pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
Taming the Chaos: How to Turn Unstructured Data into Decisions
A contest of sentiment analysis: k-nearest neighbor versus neural network
search engine optimization ppt fir known well about this
Benefits of Physical activity for teenagers.pptx
CloudStack 4.21: First Look Webinar slides
The various Industrial Revolutions .pptx
Module 1.ppt Iot fundamentals and Architecture
DP Operators-handbook-extract for the Mautical Institute
Assigned Numbers - 2025 - Bluetooth® Document
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
A novel scalable deep ensemble learning framework for big data classification...
Hybrid model detection and classification of lung cancer
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Modernising the Digital Integration Hub
STKI Israel Market Study 2025 version august
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Chapter 5: Probability Theory and Statistics
Tartificialntelligence_presentation.pptx
1 - Historical Antecedents, Social Consideration.pdf
Group 1 Presentation -Planning and Decision Making .pptx

PowerShell: Automation for everyone

Editor's Notes

  • #8: Cmdlets take the form of <verb>-<noun> or <verb>-<noun group>Get-Help takes wildcards and can help you find whole groups of commandsAlias: gcm
  • #9: Every PowerShellCmdlet is REQUIRED to have a help entry.It’s is NOT required to be right howeverNo Alias
  • #10: Allows you to see what type and which properties and methods are on objects which are returned.Alias: gm
  • #11: Used to filter sets of object Alias:?
  • #12: Used to perform operations of a series of calls using a single object in a collectionAlias:%
  • #14: Short demo ~2mins showing the use of Get-Command, Get-Help and Get-Member
  • #15: 3 Quick demos of using the pipelineDemo 1) Show scraping photos off mum’s memory card to a local photo directory.Demo 2) Kill devenvDemo 3) Show the file re-name example
  • #21: Cmdlet binding attribute: Checks for argument overflow (normally allowed and put into $args[]) Allows autogeneration of positional parameters, Toggle availability when remoting, default parameter setParameter binding attribute: Mandatory? Parameter sets Parameter position Accept value from pipeline