SlideShare a Scribd company logo
10 POWERSHELL MISTAKES, 
TRIP-UPS AND TRAPS 
JEFFERY HICKS 
PROF. POWERSHELL
WHO AM I? 
• Windows PowerShell MVP 
• PowerShell Author 
• Learn PowerShell 3 in a Month of Lunches (with Don Jones) 
• Learn PowerShell Toolmaking in a Month of Lunches (with Don Jones) 
• PowerShell in Depth (with Don Jones & Richard Siddaway) 
• Managing Active Directory with Windows PowerShell: TFM 2nd Ed. 
• IT trainer and consultant 
• http://jdhitsolutions.com/blog 
• http://twitter.com/jeffhicks
#1 DON’T USE WRITE-HOST 
• Write-Host writes to the console, not the pipeline 
• You can only work with objects written to the pipeline 
• Puppies are hurt when you use Write-Host 
• Unless you use as intended
#2 IT’S ALL ABOUT THE OBJECTS 
• Don’t try to parse text 
• Don’t try to concatenate 
• Everything in PowerShell is an object 
• Learn how to use Get-Member
#3 BOOLEANS ARE OBJECTS, TOO 
• $True and $False are not strings 
• The cool PowerShell kids don’t compare
#4 DON’T FALL INTO THE ALIAS TRAP 
• Aliases are fine for interactive sessions 
• You know what you’re typing 
• Aliases disguise the real command
#5 VARIABLE VULNERABILITY 
• This isn’t VBScript 
• Variable names should be meaningful 
• Avoid re-using variables for different object types
#6 POWERSHELL IS NOT .NET PROGRAMMING 
• Use cmdlets wherever possible 
• .NET classes and methods are for exceptions 
• …or large scale performance benefits
#7 POWERSHELL IS NOT VBSCRIPT 
• PowerShell requires a new paradigm 
• Don’t turn VBScript into PowerShell 
• Objects in the pipeline
#8 DON’T MAKE ERRORS GO AWAY 
• Don’t turn off error pipeline 
• $ErrorActionPreference = "SilentlyContinue" 
• Makes troubleshooting more difficult 
• Use Try/Catch and learn how to handle errors
#9 DON’T RE-INVENT THE WHEEL 
• Don’t try to duplicate PowerShell functionality 
• No need to write your own help routine 
• Don’t try to re-invent cmdlets using .NET
#10 NOT EVERYTHING IS A ONE-LINER 
• One-line commands can be efficient 
• Great for interactive console 
• Not necessarily a benefit in scripting 
• Don’t code yourself into a corner
QUESTIONS AND ANSWERS
RECOMMENDATIONS 
• Write objects to the pipeline 
• Use cmdlets where possible 
• No aliases or shortcuts in scripts 
• Learn how to handle errors 
• Read the help and examples
RESOURCES 
• Learn PowerShell 3 in a Month of Lunches by Don Jones and Jeffery 
Hicks 
• Learn PowerShell Toolmaking in a Month of Lunches by Don Jones 
and Jeffery Hicks 
• The Lonely Administrator (http://jdhitsolutions.com/blog) 
• Prof. PowerShell (http://mcpmag.com/articles/list/prof-powershell. 
aspx 
• PowerShell.org
THANK YOU 
http://jdhitsolutions.com/blog 
jhicks@jdhitsolutions.com 
@JeffHicks 
http://gplus.to/jeffhicks

More Related Content

What's hot

BathCamp #32 - CMS Smackdown! - Plone
BathCamp #32 - CMS Smackdown! - PloneBathCamp #32 - CMS Smackdown! - Plone
BathCamp #32 - CMS Smackdown! - Plone
Matt Hamilton
 
Windows: Having it's ass kicked by Puppet and PowerShell since 2012
Windows: Having it's ass kicked by Puppet and PowerShell since 2012Windows: Having it's ass kicked by Puppet and PowerShell since 2012
Windows: Having it's ass kicked by Puppet and PowerShell since 2012Paul Stack
 
Untangling - fall2017 - week6
Untangling - fall2017 - week6Untangling - fall2017 - week6
Untangling - fall2017 - week6
Derek Jacoby
 
The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015
Christian Heilmann
 
An Introduction to CoffeeScript
An Introduction to CoffeeScriptAn Introduction to CoffeeScript
An Introduction to CoffeeScript
Ramkumar Murugadoss
 
Untangling - fall2017 - week5
Untangling - fall2017 - week5Untangling - fall2017 - week5
Untangling - fall2017 - week5
Derek Jacoby
 
The State of the Web - Helsinki meetup
The State of the Web - Helsinki meetupThe State of the Web - Helsinki meetup
The State of the Web - Helsinki meetup
Christian Heilmann
 
Using Wordpress To Share Research
Using Wordpress To Share ResearchUsing Wordpress To Share Research
Using Wordpress To Share Research
Jeremy Boggs
 
Moore vs. May - everything is faster and better: we can fix that
Moore vs. May - everything is faster and better: we can fix thatMoore vs. May - everything is faster and better: we can fix that
Moore vs. May - everything is faster and better: we can fix that
Christian Heilmann
 
Overboard.js - where are we going with with jsconfasia / devfestasia
Overboard.js - where are we going with with jsconfasia / devfestasiaOverboard.js - where are we going with with jsconfasia / devfestasia
Overboard.js - where are we going with with jsconfasia / devfestasia
Christian Heilmann
 
Did i do the right thing show
Did i do the right thing showDid i do the right thing show
Did i do the right thing showFajri Abdillah
 
Orchestrating Content
Orchestrating ContentOrchestrating Content
Orchestrating Content
Sara Wachter-Boettcher
 
Power to the People: Manipulating SharePoint with Client-Side JavaScript
Power to the People:  Manipulating SharePoint with Client-Side JavaScriptPower to the People:  Manipulating SharePoint with Client-Side JavaScript
Power to the People: Manipulating SharePoint with Client-Side JavaScript
PeterBrunone
 
Erase and Rewind - Open Web Camp 2015
Erase and Rewind - Open Web Camp 2015Erase and Rewind - Open Web Camp 2015
Erase and Rewind - Open Web Camp 2015
Christian Heilmann
 
A pinch of indirection, and don't cut yourself chopping onions...
A pinch of indirection, and don't cut yourself chopping onions...A pinch of indirection, and don't cut yourself chopping onions...
A pinch of indirection, and don't cut yourself chopping onions...
Sean Upton
 
Did i do the right thing?
Did i do the right thing?Did i do the right thing?
Did i do the right thing?
Fajri Abdillah
 
In It Together: Co-Creating Your Content Strategy
In It Together: Co-Creating Your Content StrategyIn It Together: Co-Creating Your Content Strategy
In It Together: Co-Creating Your Content Strategy
Sara Wachter-Boettcher
 
A novel approach to Undo
A novel approach to UndoA novel approach to Undo
A novel approach to Undo
Sean Upton
 
Moving Your Library to Web 2.0 and Beyond
Moving Your Library to Web 2.0 and BeyondMoving Your Library to Web 2.0 and Beyond
Moving Your Library to Web 2.0 and Beyond
Beckiemac
 

What's hot (20)

BathCamp #32 - CMS Smackdown! - Plone
BathCamp #32 - CMS Smackdown! - PloneBathCamp #32 - CMS Smackdown! - Plone
BathCamp #32 - CMS Smackdown! - Plone
 
Windows: Having it's ass kicked by Puppet and PowerShell since 2012
Windows: Having it's ass kicked by Puppet and PowerShell since 2012Windows: Having it's ass kicked by Puppet and PowerShell since 2012
Windows: Having it's ass kicked by Puppet and PowerShell since 2012
 
Untangling - fall2017 - week6
Untangling - fall2017 - week6Untangling - fall2017 - week6
Untangling - fall2017 - week6
 
The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015
 
An Introduction to CoffeeScript
An Introduction to CoffeeScriptAn Introduction to CoffeeScript
An Introduction to CoffeeScript
 
Dynamic Website
Dynamic WebsiteDynamic Website
Dynamic Website
 
Untangling - fall2017 - week5
Untangling - fall2017 - week5Untangling - fall2017 - week5
Untangling - fall2017 - week5
 
The State of the Web - Helsinki meetup
The State of the Web - Helsinki meetupThe State of the Web - Helsinki meetup
The State of the Web - Helsinki meetup
 
Using Wordpress To Share Research
Using Wordpress To Share ResearchUsing Wordpress To Share Research
Using Wordpress To Share Research
 
Moore vs. May - everything is faster and better: we can fix that
Moore vs. May - everything is faster and better: we can fix thatMoore vs. May - everything is faster and better: we can fix that
Moore vs. May - everything is faster and better: we can fix that
 
Overboard.js - where are we going with with jsconfasia / devfestasia
Overboard.js - where are we going with with jsconfasia / devfestasiaOverboard.js - where are we going with with jsconfasia / devfestasia
Overboard.js - where are we going with with jsconfasia / devfestasia
 
Did i do the right thing show
Did i do the right thing showDid i do the right thing show
Did i do the right thing show
 
Orchestrating Content
Orchestrating ContentOrchestrating Content
Orchestrating Content
 
Power to the People: Manipulating SharePoint with Client-Side JavaScript
Power to the People:  Manipulating SharePoint with Client-Side JavaScriptPower to the People:  Manipulating SharePoint with Client-Side JavaScript
Power to the People: Manipulating SharePoint with Client-Side JavaScript
 
Erase and Rewind - Open Web Camp 2015
Erase and Rewind - Open Web Camp 2015Erase and Rewind - Open Web Camp 2015
Erase and Rewind - Open Web Camp 2015
 
A pinch of indirection, and don't cut yourself chopping onions...
A pinch of indirection, and don't cut yourself chopping onions...A pinch of indirection, and don't cut yourself chopping onions...
A pinch of indirection, and don't cut yourself chopping onions...
 
Did i do the right thing?
Did i do the right thing?Did i do the right thing?
Did i do the right thing?
 
In It Together: Co-Creating Your Content Strategy
In It Together: Co-Creating Your Content StrategyIn It Together: Co-Creating Your Content Strategy
In It Together: Co-Creating Your Content Strategy
 
A novel approach to Undo
A novel approach to UndoA novel approach to Undo
A novel approach to Undo
 
Moving Your Library to Web 2.0 and Beyond
Moving Your Library to Web 2.0 and BeyondMoving Your Library to Web 2.0 and Beyond
Moving Your Library to Web 2.0 and Beyond
 

Viewers also liked

PowerShell Core Skills (TechMentor Fall 2011)
PowerShell Core Skills (TechMentor Fall 2011)PowerShell Core Skills (TechMentor Fall 2011)
PowerShell Core Skills (TechMentor Fall 2011)Concentrated Technology
 
PowerShell Scripting and Modularization (TechMentor Fall 2011)
PowerShell Scripting and Modularization (TechMentor Fall 2011)PowerShell Scripting and Modularization (TechMentor Fall 2011)
PowerShell Scripting and Modularization (TechMentor Fall 2011)Concentrated Technology
 
Introduction to Desired State Configuration (DSC)
Introduction to Desired State Configuration (DSC)Introduction to Desired State Configuration (DSC)
Introduction to Desired State Configuration (DSC)
Jeffery Hicks
 
Introduction To Power Shell
Introduction To Power ShellIntroduction To Power Shell
Introduction To Power Shell
Ivan Suhinin
 
Wsv315 Windows Power Shell For Beginners
Wsv315 Windows Power Shell For BeginnersWsv315 Windows Power Shell For Beginners
Wsv315 Windows Power Shell For Beginners
jsnover1
 
Wsv406 Advanced Automation Using Windows Power Shell2.0
Wsv406 Advanced Automation Using Windows Power Shell2.0Wsv406 Advanced Automation Using Windows Power Shell2.0
Wsv406 Advanced Automation Using Windows Power Shell2.0
jsnover1
 
Everything you need to know about PowerShell
Everything you need to know about PowerShellEverything you need to know about PowerShell
Everything you need to know about PowerShell
Shane Hoey
 
Windows 2012 R2 Multi Server Management
Windows 2012 R2 Multi Server ManagementWindows 2012 R2 Multi Server Management
Windows 2012 R2 Multi Server Management
Sharkrit JOBBO
 
VMUG - Mastering PowerShell to Call RESTful API Endpoints
VMUG - Mastering PowerShell to Call RESTful API EndpointsVMUG - Mastering PowerShell to Call RESTful API Endpoints
VMUG - Mastering PowerShell to Call RESTful API Endpoints
Chris Wahl
 
Introduction To Windows Power Shell
Introduction To Windows Power ShellIntroduction To Windows Power Shell
Introduction To Windows Power Shell
Microsoft TechNet
 
Basic PowerShell Toolmaking - Spiceworld 2016 session
Basic PowerShell Toolmaking - Spiceworld 2016 sessionBasic PowerShell Toolmaking - Spiceworld 2016 session
Basic PowerShell Toolmaking - Spiceworld 2016 session
Rob Dunn
 
Automating Active Directory mgmt in PowerShell
Automating Active Directory mgmt in PowerShellAutomating Active Directory mgmt in PowerShell
Automating Active Directory mgmt in PowerShellConcentrated Technology
 
Three cool cmdlets I wish PowerShell Had!
Three cool cmdlets I wish PowerShell Had!Three cool cmdlets I wish PowerShell Had!
Three cool cmdlets I wish PowerShell Had!
Thomas Lee
 

Viewers also liked (20)

PowerShell Core Skills (TechMentor Fall 2011)
PowerShell Core Skills (TechMentor Fall 2011)PowerShell Core Skills (TechMentor Fall 2011)
PowerShell Core Skills (TechMentor Fall 2011)
 
PowerShell Scripting and Modularization (TechMentor Fall 2011)
PowerShell Scripting and Modularization (TechMentor Fall 2011)PowerShell Scripting and Modularization (TechMentor Fall 2011)
PowerShell Scripting and Modularization (TechMentor Fall 2011)
 
Introduction to Desired State Configuration (DSC)
Introduction to Desired State Configuration (DSC)Introduction to Desired State Configuration (DSC)
Introduction to Desired State Configuration (DSC)
 
Introduction To Power Shell
Introduction To Power ShellIntroduction To Power Shell
Introduction To Power Shell
 
Wsv315 Windows Power Shell For Beginners
Wsv315 Windows Power Shell For BeginnersWsv315 Windows Power Shell For Beginners
Wsv315 Windows Power Shell For Beginners
 
Wsv406 Advanced Automation Using Windows Power Shell2.0
Wsv406 Advanced Automation Using Windows Power Shell2.0Wsv406 Advanced Automation Using Windows Power Shell2.0
Wsv406 Advanced Automation Using Windows Power Shell2.0
 
Everything you need to know about PowerShell
Everything you need to know about PowerShellEverything you need to know about PowerShell
Everything you need to know about PowerShell
 
Windows 2012 R2 Multi Server Management
Windows 2012 R2 Multi Server ManagementWindows 2012 R2 Multi Server Management
Windows 2012 R2 Multi Server Management
 
VMUG - Mastering PowerShell to Call RESTful API Endpoints
VMUG - Mastering PowerShell to Call RESTful API EndpointsVMUG - Mastering PowerShell to Call RESTful API Endpoints
VMUG - Mastering PowerShell to Call RESTful API Endpoints
 
Introduction To Windows Power Shell
Introduction To Windows Power ShellIntroduction To Windows Power Shell
Introduction To Windows Power Shell
 
Managing SQLserver
Managing SQLserverManaging SQLserver
Managing SQLserver
 
Combining output from multiple sources
Combining output from multiple sourcesCombining output from multiple sources
Combining output from multiple sources
 
Basic PowerShell Toolmaking - Spiceworld 2016 session
Basic PowerShell Toolmaking - Spiceworld 2016 sessionBasic PowerShell Toolmaking - Spiceworld 2016 session
Basic PowerShell Toolmaking - Spiceworld 2016 session
 
Automating ad with powershell
Automating ad with powershellAutomating ad with powershell
Automating ad with powershell
 
From VB Script to PowerShell
From VB Script to PowerShellFrom VB Script to PowerShell
From VB Script to PowerShell
 
Ad disasters & how to prevent them
Ad disasters & how to prevent themAd disasters & how to prevent them
Ad disasters & how to prevent them
 
Automating Active Directory mgmt in PowerShell
Automating Active Directory mgmt in PowerShellAutomating Active Directory mgmt in PowerShell
Automating Active Directory mgmt in PowerShell
 
Three cool cmdlets I wish PowerShell Had!
Three cool cmdlets I wish PowerShell Had!Three cool cmdlets I wish PowerShell Had!
Three cool cmdlets I wish PowerShell Had!
 
PowerShell crashcourse for sharepoint
PowerShell crashcourse for sharepointPowerShell crashcourse for sharepoint
PowerShell crashcourse for sharepoint
 
Ha & drs gotcha's
Ha & drs gotcha'sHa & drs gotcha's
Ha & drs gotcha's
 

Similar to 10 PowerShell Mistakes, Trips and Traps

14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
Ike Ellis
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
Ike Ellis
 
Better Software Through User Research
Better Software Through User ResearchBetter Software Through User Research
Better Software Through User Research
Alexandra Leisse
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
Alfred Jett Grandeza
 
Ask the XPages Experts
Ask the XPages ExpertsAsk the XPages Experts
Ask the XPages Experts
Teamstudio
 
25 php interview questions – codementor
25 php interview questions – codementor25 php interview questions – codementor
25 php interview questions – codementor
Arc & Codementor
 
Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Untangling - fall2017 - week 7
Untangling - fall2017 - week 7
Derek Jacoby
 
Simple Steps to Blended Learning
Simple Steps to Blended LearningSimple Steps to Blended Learning
Simple Steps to Blended Learning
Vicki Davis
 
Simple Steps to Blended Learning
Simple Steps to Blended LearningSimple Steps to Blended Learning
Simple Steps to Blended Learning
Vicki Davis
 
Simple Steps to Blended Learning #ucet15
Simple Steps to Blended Learning #ucet15Simple Steps to Blended Learning #ucet15
Simple Steps to Blended Learning #ucet15
Vicki Davis
 
PowerShell Runspaces
PowerShell RunspacesPowerShell Runspaces
PowerShell Runspaces
Drew Furgiuele
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven developmentEinar Ingebrigtsen
 
It's XP, Stupid
It's XP, StupidIt's XP, Stupid
It's XP, Stupid
Mike Harris
 
Clean Code Talk (draft)
Clean Code Talk (draft)Clean Code Talk (draft)
Clean Code Talk (draft)
Daniel Deutsch, LL.M. (WU)
 
12 Things Every Programmer Should Know
12 Things Every Programmer Should Know12 Things Every Programmer Should Know
12 Things Every Programmer Should Know
Samnang Chhun
 
How To Write a Testable Code
How To Write a Testable CodeHow To Write a Testable Code
How To Write a Testable Code
OPIN Software Inc.
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair Programming
Steven Smith
 
Contribute 101: Engine/Swarm/ContainerD by Phil Estes
Contribute 101: Engine/Swarm/ContainerD by Phil EstesContribute 101: Engine/Swarm/ContainerD by Phil Estes
Contribute 101: Engine/Swarm/ContainerD by Phil Estes
Docker, Inc.
 
Writing clean and maintainable code
Writing clean and maintainable codeWriting clean and maintainable code
Writing clean and maintainable code
Marko Heijnen
 
How to Empower Clients to Use their Websites – and Client-proof them at the S...
How to Empower Clients to Use their Websites – and Client-proof them at the S...How to Empower Clients to Use their Websites – and Client-proof them at the S...
How to Empower Clients to Use their Websites – and Client-proof them at the S...
Michelle Ames
 

Similar to 10 PowerShell Mistakes, Trips and Traps (20)

14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
 
Better Software Through User Research
Better Software Through User ResearchBetter Software Through User Research
Better Software Through User Research
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
 
Ask the XPages Experts
Ask the XPages ExpertsAsk the XPages Experts
Ask the XPages Experts
 
25 php interview questions – codementor
25 php interview questions – codementor25 php interview questions – codementor
25 php interview questions – codementor
 
Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Untangling - fall2017 - week 7
Untangling - fall2017 - week 7
 
Simple Steps to Blended Learning
Simple Steps to Blended LearningSimple Steps to Blended Learning
Simple Steps to Blended Learning
 
Simple Steps to Blended Learning
Simple Steps to Blended LearningSimple Steps to Blended Learning
Simple Steps to Blended Learning
 
Simple Steps to Blended Learning #ucet15
Simple Steps to Blended Learning #ucet15Simple Steps to Blended Learning #ucet15
Simple Steps to Blended Learning #ucet15
 
PowerShell Runspaces
PowerShell RunspacesPowerShell Runspaces
PowerShell Runspaces
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
 
It's XP, Stupid
It's XP, StupidIt's XP, Stupid
It's XP, Stupid
 
Clean Code Talk (draft)
Clean Code Talk (draft)Clean Code Talk (draft)
Clean Code Talk (draft)
 
12 Things Every Programmer Should Know
12 Things Every Programmer Should Know12 Things Every Programmer Should Know
12 Things Every Programmer Should Know
 
How To Write a Testable Code
How To Write a Testable CodeHow To Write a Testable Code
How To Write a Testable Code
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair Programming
 
Contribute 101: Engine/Swarm/ContainerD by Phil Estes
Contribute 101: Engine/Swarm/ContainerD by Phil EstesContribute 101: Engine/Swarm/ContainerD by Phil Estes
Contribute 101: Engine/Swarm/ContainerD by Phil Estes
 
Writing clean and maintainable code
Writing clean and maintainable codeWriting clean and maintainable code
Writing clean and maintainable code
 
How to Empower Clients to Use their Websites – and Client-proof them at the S...
How to Empower Clients to Use their Websites – and Client-proof them at the S...How to Empower Clients to Use their Websites – and Client-proof them at the S...
How to Empower Clients to Use their Websites – and Client-proof them at the S...
 

Recently uploaded

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 

Recently uploaded (20)

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 

10 PowerShell Mistakes, Trips and Traps

  • 1. 10 POWERSHELL MISTAKES, TRIP-UPS AND TRAPS JEFFERY HICKS PROF. POWERSHELL
  • 2. WHO AM I? • Windows PowerShell MVP • PowerShell Author • Learn PowerShell 3 in a Month of Lunches (with Don Jones) • Learn PowerShell Toolmaking in a Month of Lunches (with Don Jones) • PowerShell in Depth (with Don Jones & Richard Siddaway) • Managing Active Directory with Windows PowerShell: TFM 2nd Ed. • IT trainer and consultant • http://jdhitsolutions.com/blog • http://twitter.com/jeffhicks
  • 3. #1 DON’T USE WRITE-HOST • Write-Host writes to the console, not the pipeline • You can only work with objects written to the pipeline • Puppies are hurt when you use Write-Host • Unless you use as intended
  • 4. #2 IT’S ALL ABOUT THE OBJECTS • Don’t try to parse text • Don’t try to concatenate • Everything in PowerShell is an object • Learn how to use Get-Member
  • 5. #3 BOOLEANS ARE OBJECTS, TOO • $True and $False are not strings • The cool PowerShell kids don’t compare
  • 6. #4 DON’T FALL INTO THE ALIAS TRAP • Aliases are fine for interactive sessions • You know what you’re typing • Aliases disguise the real command
  • 7. #5 VARIABLE VULNERABILITY • This isn’t VBScript • Variable names should be meaningful • Avoid re-using variables for different object types
  • 8. #6 POWERSHELL IS NOT .NET PROGRAMMING • Use cmdlets wherever possible • .NET classes and methods are for exceptions • …or large scale performance benefits
  • 9. #7 POWERSHELL IS NOT VBSCRIPT • PowerShell requires a new paradigm • Don’t turn VBScript into PowerShell • Objects in the pipeline
  • 10. #8 DON’T MAKE ERRORS GO AWAY • Don’t turn off error pipeline • $ErrorActionPreference = "SilentlyContinue" • Makes troubleshooting more difficult • Use Try/Catch and learn how to handle errors
  • 11. #9 DON’T RE-INVENT THE WHEEL • Don’t try to duplicate PowerShell functionality • No need to write your own help routine • Don’t try to re-invent cmdlets using .NET
  • 12. #10 NOT EVERYTHING IS A ONE-LINER • One-line commands can be efficient • Great for interactive console • Not necessarily a benefit in scripting • Don’t code yourself into a corner
  • 14. RECOMMENDATIONS • Write objects to the pipeline • Use cmdlets where possible • No aliases or shortcuts in scripts • Learn how to handle errors • Read the help and examples
  • 15. RESOURCES • Learn PowerShell 3 in a Month of Lunches by Don Jones and Jeffery Hicks • Learn PowerShell Toolmaking in a Month of Lunches by Don Jones and Jeffery Hicks • The Lonely Administrator (http://jdhitsolutions.com/blog) • Prof. PowerShell (http://mcpmag.com/articles/list/prof-powershell. aspx • PowerShell.org
  • 16. THANK YOU http://jdhitsolutions.com/blog jhicks@jdhitsolutions.com @JeffHicks http://gplus.to/jeffhicks

Editor's Notes

  1. Windows PowerShell is a language and management technology that many IT professionals, including developers, think they understand. Yet very often they get caught up in pre-conceptions and misinterpretations, usually based on prior experience with scripting or development. This session will explore the 10 most common mistakes and traps that people fall into with PowerShell and how to avoid them.