SlideShare a Scribd company logo
M o d e r n i z i n g Po w e r S h e l l S c r i p t s
whoami
• Matthias van den Elsacker
• Axxes since 2014
• System Engineer @ Umicore since 2014
• First Line for 1 year
• Second/Third Line SCCM for 4 years
• Network Engineer @ Umicore since 2019
• Contact: Matthias.vandenElsacker@axxes.com
Introduction
Why this session
My Collection of Scripts
Where did I leave these again?
Problem? Solution!
Talking points
• Best practices
• PowerShell to PowerShell Core
• Cross Platform
• ISE to Visual Studio Code
• Git
• Pester
Best Practices
And style rules
lowercase, PascalCase, UPPERCASE
• lowercase: Powershell Keywords
• foreach, switch, return, -eq, -like,…
• PascalCase: All public identifiers
• Functions, Modules, Cmdlets, Attributes, Classes,…
• Do-Something, $SomeVariable, MyModule.psm1,…
• UPPERCASE: Comment-based help keywords
• .SYNOPSIS, .EXAMPLE, .DESCRIPTION,…
“One True Brace Style”
• Brackets open at the end of a line.
• Brackets close at the beginning of a line.
• Exception: short CommandBlocks.
Verb-Noun
• All PowerShell Modules, Functions and Cmdlets follow this rule.
• Get-Process, New-LocalUser, Clear-Content,…
• Follow this rule when creating functions.
• Repair-Wmi, Add-DomainUserToLocalAdmins, Get-
RootCertificatesFromComputer
• List of approved Verbs:
• Get-Verb
Modernizing PowerShell Scripts
Aliases
• Aliases are cool and all, but…
• … make code hard to understand.
• So try to avoid them.
• (Unless you are playing Code Golf)
Comments
• Comments should be useful.
• Not useful:
• Useful:
Other Best Practices
Modernizing PowerShell Scripts
Modernizing PowerShell Scripts
Modernizing PowerShell Scripts
Modernizing PowerShell Scripts
Other Best Practices
• Re-usability
Modernizing PowerShell Scripts
Modernizing PowerShell Scripts
Other Best Practices
• Re-usability
• Modularity
Modernizing PowerShell Scripts
Modernizing PowerShell Scripts
Other Best Practices
• Re-usability
• Modularity
• Don’t re-invent the wheel
Modernizing PowerShell Scripts
Other Best Practices
• Re-usability
• Modularity
• Don’t re-invent the wheel
• Write-*
PowerShell to PS Core
Moving to an open-source, cross-platform version
Modernizing PowerShell Scripts
What’s broken?
Solution!
What’s broken?
Solution!
What’s broken?
Solution!
Solution!
What’s broken?
Solution?
PowerShell Core keeps evolving…
What about Linux?
Cross-Platform PowerShell
PowerShell comes in a lot of flavors
Remote Connection to Linux
Remote Connection to Linux
Windows vs Linux
ISE vs Code
Out with the old, in with the new
In Memoriam
Welcome Visual Studio Code
Main advantages
• Workspaces, folders, and files
• Add-ons
• Themes
• Cross Platform
• Debugging
• Multiple terminals
• Integrated GIT
• Not just for PowerShell
• It’s just cooler
Git
And GitHub for System Engineers
“A solution for growing pains”
G-I-T
• Random three-letter combination that is pronounceable, and not actually
used by any common UNIX command. The fact that it is a
mispronunciation of "get" may or may not be relevant.
• Stupid. Contemptible and Despicable. Simple. Take your pick from the
dictionary of slang.
• “Global information tracker": you're in a good mood, and it actually works
for you. Angels sing, and a light suddenly fills the room.
• “Goddamn idiotic truckload of sh*t": when it breaks
Modernizing PowerShell Scripts
Modernizing PowerShell Scripts
Pester
Testing PowerShell, using PowerShell
Pester
• Test Framework
• For PowerShell
• Written in PowerShell
• DSL Syntax:
• “Describe”
• “It”
• “Should”
Type of Tests
• Unit Testing
• In isolation (using $TestDrive)
• No external code (using Mocks)
• Integration Testing
• “White/Clear Box Testing”
• Integration with external code
• Acceptance Testing
• “Black Box Testing”
• Third party
T h a n k y o u !
Resources
• https://github.com/PoshCode/PowerShellPracticeAndStyle
• https://poshcode.gitbooks.io/powershell-practice-and-style/
• https://docs.microsoft.com/en-us/powershell/scripting/whats-new/breaking-changes-ps6?view=powershell-6
• https://4sysops.com/archives/make-visual-studio-code-look-and-behave-like-powershell-ise/
• https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/ssh-remoting-in-powershell-
core?view=powershell-6
• https://github.com/PowerShell/psl-omi-provider
• https://lkml.org/lkml/1998/9/30/122
• https://guides.github.com/activities/hello-world/
• https://github.com/pester/Pester
• https://www.red-gate.com/simple-talk/sysadmin/powershell/introduction-to-testing-your-powershell-code-with-
pester/

More Related Content

What's hot (20)

PDF
Stable Squeak World Tour
ESUG
 
PPTX
On premise cross-browser testing
Daniel Herken
 
PPTX
Azure Bicep - An Introduction
Ravikanth Chaganti
 
PDF
Immutable infrastructure with Boxfuse
Lars Östling
 
PDF
The Architect Way - JSCamp.asia 2012
Jan Jongboom
 
PDF
Playing with playgrounds
Eurico Doirado
 
PPTX
Goodbye Flash, Hello OpenFL: Next Generation Cross-Platform Game Development
Jessica Tams
 
PDF
The Three Musketeers
Frederic Lemay
 
PPTX
Generalization in Auto-Testing. How we put what we had into new Technological...
SQALab
 
PPTX
Azure at the command line
Ravikanth Chaganti
 
PDF
Game Programming 00 - Exams
Nick Pruehs
 
PDF
Open.source.innovation.20070624
Vu Hung Nguyen
 
PDF
Docker
Knoldus Inc.
 
PDF
Meet the Selenium Grid
Alexey Nikolaenko
 
PDF
Wilko Nienhaus - continuous delivery release the right thing, done right, at ...
DevConFu
 
PDF
Perl-Critic
Jonas Brømsø
 
PPTX
Go Fast, Go Safe, Go on Vacation - Compuware ISPW Webcast
Compuware
 
PPTX
Power shell v3 session1
Vladimir Márquez
 
PPTX
Final presentation
Brandon Barclay
 
PPTX
Docker and Jenkins Pipeline
Mark Waite
 
Stable Squeak World Tour
ESUG
 
On premise cross-browser testing
Daniel Herken
 
Azure Bicep - An Introduction
Ravikanth Chaganti
 
Immutable infrastructure with Boxfuse
Lars Östling
 
The Architect Way - JSCamp.asia 2012
Jan Jongboom
 
Playing with playgrounds
Eurico Doirado
 
Goodbye Flash, Hello OpenFL: Next Generation Cross-Platform Game Development
Jessica Tams
 
The Three Musketeers
Frederic Lemay
 
Generalization in Auto-Testing. How we put what we had into new Technological...
SQALab
 
Azure at the command line
Ravikanth Chaganti
 
Game Programming 00 - Exams
Nick Pruehs
 
Open.source.innovation.20070624
Vu Hung Nguyen
 
Docker
Knoldus Inc.
 
Meet the Selenium Grid
Alexey Nikolaenko
 
Wilko Nienhaus - continuous delivery release the right thing, done right, at ...
DevConFu
 
Perl-Critic
Jonas Brømsø
 
Go Fast, Go Safe, Go on Vacation - Compuware ISPW Webcast
Compuware
 
Power shell v3 session1
Vladimir Márquez
 
Final presentation
Brandon Barclay
 
Docker and Jenkins Pipeline
Mark Waite
 

Similar to Modernizing PowerShell Scripts (20)

PPTX
Holy PowerShell, BATman! - dogfood edition
Dave Diehl
 
PPTX
Professional Help for PowerShell Modules
June Blender
 
PPTX
Microsoft ASP.NET 5 - The new kid on the block
Christos Matskas
 
PPTX
It's XP Stupid (2019)
Mike Harris
 
PDF
Cv fayaz
Fayaz Yusuf Khan
 
PPTX
Extreme Programming (XP): Revisted
Mike Harris
 
PDF
It's XP, Stupid
Mike Harris
 
PPT
David buksbaum a-briefintroductiontocsharp
Jorge Antonio Contre Vargas
 
PPTX
Вредные советы .NET разработчикам, Сергей Калинец
Sigma Software
 
PPTX
PowerShell 101 - What is it and Why should YOU Care!
Thomas Lee
 
PPTX
Coding Standard And Code Review
Milan Vukoje
 
PDF
What we talk about when we talk about DevOps
Ricard Clau
 
PPTX
ASP.NET 5 - Microsoft's Web development platform reimagined
Alex Thissen
 
PPTX
.NET per la Data Science e oltre
Marco Parenzan
 
PDF
DSL's with Groovy
paulbowler
 
PPS
CS101- Introduction to Computing- Lecture 45
Bilal Ahmed
 
KEY
Driving application development through behavior driven development
Einar Ingebrigtsen
 
PDF
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
Howard Greenberg
 
PPTX
PowerShell for Penetration Testers
Nikhil Mittal
 
PPTX
Hidden Treasure - TestComplete Script Extensions
SmartBear
 
Holy PowerShell, BATman! - dogfood edition
Dave Diehl
 
Professional Help for PowerShell Modules
June Blender
 
Microsoft ASP.NET 5 - The new kid on the block
Christos Matskas
 
It's XP Stupid (2019)
Mike Harris
 
Extreme Programming (XP): Revisted
Mike Harris
 
It's XP, Stupid
Mike Harris
 
David buksbaum a-briefintroductiontocsharp
Jorge Antonio Contre Vargas
 
Вредные советы .NET разработчикам, Сергей Калинец
Sigma Software
 
PowerShell 101 - What is it and Why should YOU Care!
Thomas Lee
 
Coding Standard And Code Review
Milan Vukoje
 
What we talk about when we talk about DevOps
Ricard Clau
 
ASP.NET 5 - Microsoft's Web development platform reimagined
Alex Thissen
 
.NET per la Data Science e oltre
Marco Parenzan
 
DSL's with Groovy
paulbowler
 
CS101- Introduction to Computing- Lecture 45
Bilal Ahmed
 
Driving application development through behavior driven development
Einar Ingebrigtsen
 
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
Howard Greenberg
 
PowerShell for Penetration Testers
Nikhil Mittal
 
Hidden Treasure - TestComplete Script Extensions
SmartBear
 
Ad

More from Axxes IT Consultancy (6)

PDF
Slides blockchain sessies Kristof verslype
Axxes IT Consultancy
 
PPTX
Axxes tax hackers
Axxes IT Consultancy
 
PDF
Security Basics - Internet Safety
Axxes IT Consultancy
 
PDF
Futureproof angular 1.x applications - yannick houbrix
Axxes IT Consultancy
 
PDF
Pitfalls in Performance Testing AxxesCC 06/2015
Axxes IT Consultancy
 
PPTX
Axxes software development traineeship
Axxes IT Consultancy
 
Slides blockchain sessies Kristof verslype
Axxes IT Consultancy
 
Axxes tax hackers
Axxes IT Consultancy
 
Security Basics - Internet Safety
Axxes IT Consultancy
 
Futureproof angular 1.x applications - yannick houbrix
Axxes IT Consultancy
 
Pitfalls in Performance Testing AxxesCC 06/2015
Axxes IT Consultancy
 
Axxes software development traineeship
Axxes IT Consultancy
 
Ad

Recently uploaded (20)

PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
Top Managed Service Providers in Los Angeles
Captain IT
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 

Modernizing PowerShell Scripts