SlideShare a Scribd company logo
1 of 23
Scripting as a
Second Language
Basic PowerShell Toolmaking
Rob Dunn - @maximillianx
• Lead Systems Administrator
• IT Pro for 22 years
• In the Spiceworks Community since 2007
• Pure Capsaicin since 2014
Sponsored by Netwrix – www.netwrix.com
Free products:
• Change Notifier for AD, File Servers, Group Policy
• Account Lockout Examiner Tool
• Password Expiration Notifier
• Effective Permissions Analyzer
• And more!
Flagship Product:
• Audit (Active Directory, Azure AD, Oracle, SharePoint, VMware, O365, and more)
#SPICEWORLD2016
• My take on the Difference Between a Script and a Tool
• Toolmaking with a Tool (not just me), the ISE
• The Genesis of the Tool
• Demo!
What We’ll Cover
#SPICEWORLD2016
A simple script is a file containing a series of runtime
instructions which can be executed repeatedly with a
relatively specific focus which produces an expected
outcome.
Typically, the user running the script doesn’t have much, if
any control over the output.
What is a Simple Script?
#SPICEWORLD2016
• Input
• Functional
• Output
What is a Tool – Three Types
#SPICEWORLD2016
What do We Use to Make Our PowerShell Scripts
and Tools? [Demo]
Use the right tool for the job!
• Not NotePad or other text-based
editors
• Something that is “PowerShell”
aware
• This could be Visual Studio,
VSCode, Sapien PowerShell Studio,
or…the FREE Microsoft ISE.
Advantages?
1. Easily execute single lines or
sections of code
2. Tab completion of parameters,
properties & methods
3. Debugging, error discovery, and
syntax highlighting
4. Add-on support
#SPICEWORLD2016
Toolmaking: My Thought Process
Problem
Level of
Need
Output Input
#SPICEWORLD2016
Start with a bit of code that you’ve used once or twice and build your script
around that.
Today’s Method: Build From the “Inside Out”
 Get-Command - Find that cmdlet you’re looking for
 Get-Help (RTFM, right?! Don’t forget to ‘Update-
Help’ as well!)
 Get-Member - Find out the methods and properties
associated with an object*
* Pretty much everything in PowerShell is an object
Quick review: Cmdlets you must know
Quick review: What is a PowerShell Object?
It’s a “thing” that represents
something.
You can also think of it like
a row in a database table -
with a twist
Properties
• $Friend.FirstName = Scott
• $Friend.LastName = Brosnan
• $Friend.Height = 1.7272
• $Friend.Funny = $True
• $Friend.BurnsUnderAStreetL
ampBecauseHeMustBeAVam
pireNotATwilightVampireThe
OtherKind= $True
$Chair
$Friend = Get-Friend | Where-Object FirstName –eq “Scott”
$Friend.BeatBox(20)
$Friend
Methods
• $Friend.Complain
• $Friend.TellHorribleJoke
• $Friend.TakeDownStorage
Array
• $Friend.BeatBox
Quick review: What is a PowerShell Object?
It’s a “thing” that represents
something.
You can also think of it like
a row in a database table -
with a twist
$Chair
$Friend = Get-Friend | Where-Object FirstName –eq “Scott”
$Friend.BeatBox(20)
$Friend
Get Event Log Entries surrounding an item of interest
The Scenario
#SPICEWORLD2016
#SPICEWORLD2016
The Problem
A service account is experiencing a lockout in the middle of the night.
IT needs to gather all the event log entries from the system log x minutes
before and x minutes after the time of a specified event to see if there is
“something else” going on.
#SPICEWORLD2016
The IT manager has determined this problem occurs enough times to warrant a
closer look at the symptoms by his junior staff; preferably by utilizing a
consistent method when the problem recurs.
The Level Of Need
#SPICEWORLD2016
The IT manager would like to have all the surrounding event log entries in a
view which can be browsed or exported to CSV for further analysis; potentially
in Excel so they can compare them.
The Output
#SPICEWORLD2016
1. The date and time of Event we’re interested in
2. The range of minutes before and after the event to gather other possible
interesting information.
The Input (our Parameters)
#SPICEWORLD2016
…find system event log items x minutes before and x
minutes after event of interest occurs
…output events to end user as objects
BONUS:
Can we get these items from ALL event logs?
To use these parameters, our script needs to:
Let’s Code!
#SPICEWORLD2016
#SPICEWORLD2016
• Comment-Based Help
• Format your script – look like a Pro!
• Make your scripts and functions single purpose, name them accordingly
• Use Microsoft supported verbs to name your functions and scripts (Get-
Verb)
• Configure Execution Policy to run PS1 files (Set-ExecutionPolicy –
ExecutionPolicy RemoteSigned, etc.)
Best Practices
#SPICEWORLD2016
1. Save your file as a .PS1 and share with your co-workers
2. Create a module (easier than it sounds)
Share and Enjoy! I.e. Extra Credit 
#SPICEWORLD2016
[Book] PowerShell in a Month of Lunches, Don Jones &
Jeffery Hicks
[Book] PowerShell ToolMaking in a Month of Lunches, Don
Jones & Jeffery Hicks
[Web] PowerShell 3.0 JumpStart, Microsoft Virtual
Academy, Jason Helmick, Jeffery Snover*
*heck, anything by Jeffery Snover, I mean, he invented it!
Learning PowerShell?
Thank you!

More Related Content

What's hot

State-of-the-Art Drupal Search with Apache Solr
State-of-the-Art Drupal Search with Apache SolrState-of-the-Art Drupal Search with Apache Solr
State-of-the-Art Drupal Search with Apache Solrguest432cd6
 
Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Edmund Turbin
 
Building Social Tools
Building Social ToolsBuilding Social Tools
Building Social ToolsAnand Hemmige
 
Drupal security
Drupal securityDrupal security
Drupal securityJozef Toth
 
How to start developing apps for Firefox OS
How to start developing apps for Firefox OSHow to start developing apps for Firefox OS
How to start developing apps for Firefox OSbenko
 
On-page SEO for Drupal
On-page SEO for DrupalOn-page SEO for Drupal
On-page SEO for DrupalSvilen Sabev
 
Etsy Search: How We Index and Query 26 Million One-of-a-kind Items
Etsy Search: How We Index and Query 26 Million One-of-a-kind ItemsEtsy Search: How We Index and Query 26 Million One-of-a-kind Items
Etsy Search: How We Index and Query 26 Million One-of-a-kind ItemsC4Media
 

What's hot (13)

Building a spa_in_30min
Building a spa_in_30minBuilding a spa_in_30min
Building a spa_in_30min
 
State-of-the-Art Drupal Search with Apache Solr
State-of-the-Art Drupal Search with Apache SolrState-of-the-Art Drupal Search with Apache Solr
State-of-the-Art Drupal Search with Apache Solr
 
Cain & Obenland — Episode 4
Cain & Obenland — Episode 4Cain & Obenland — Episode 4
Cain & Obenland — Episode 4
 
Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?
 
Building Social Tools
Building Social ToolsBuilding Social Tools
Building Social Tools
 
Drupal security
Drupal securityDrupal security
Drupal security
 
Elastic Search
Elastic SearchElastic Search
Elastic Search
 
How to start developing apps for Firefox OS
How to start developing apps for Firefox OSHow to start developing apps for Firefox OS
How to start developing apps for Firefox OS
 
How Solr Search Works
How Solr Search WorksHow Solr Search Works
How Solr Search Works
 
Open Source Search FTW
Open Source Search FTWOpen Source Search FTW
Open Source Search FTW
 
Relate
RelateRelate
Relate
 
On-page SEO for Drupal
On-page SEO for DrupalOn-page SEO for Drupal
On-page SEO for Drupal
 
Etsy Search: How We Index and Query 26 Million One-of-a-kind Items
Etsy Search: How We Index and Query 26 Million One-of-a-kind ItemsEtsy Search: How We Index and Query 26 Million One-of-a-kind Items
Etsy Search: How We Index and Query 26 Million One-of-a-kind Items
 

Viewers also liked

PowerShell Functions
PowerShell FunctionsPowerShell Functions
PowerShell Functionsmikepfeiffer
 
Automating Active Directory mgmt in PowerShell
Automating Active Directory mgmt in PowerShellAutomating Active Directory mgmt in PowerShell
Automating Active Directory mgmt in PowerShellConcentrated Technology
 
PowerShell v4 Desired State Configuration
PowerShell v4 Desired State ConfigurationPowerShell v4 Desired State Configuration
PowerShell v4 Desired State ConfigurationJason Stangroome
 
Introduction to powershell
Introduction to powershellIntroduction to powershell
Introduction to powershellSalaudeen Rajack
 
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
 
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - CertificateAdvanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - CertificateDon Reese
 

Viewers also liked (20)

Implementing dr w. hyper v clustering
Implementing dr w. hyper v clusteringImplementing dr w. hyper v clustering
Implementing dr w. hyper v clustering
 
Combining output from multiple sources
Combining output from multiple sourcesCombining output from multiple sources
Combining output from multiple sources
 
PowerShell Functions
PowerShell FunctionsPowerShell Functions
PowerShell Functions
 
PowerShell crashcourse for sharepoint
PowerShell crashcourse for sharepointPowerShell crashcourse for sharepoint
PowerShell crashcourse for sharepoint
 
Managing SQLserver
Managing SQLserverManaging SQLserver
Managing SQLserver
 
Automating Active Directory mgmt in PowerShell
Automating Active Directory mgmt in PowerShellAutomating Active Directory mgmt in PowerShell
Automating Active Directory mgmt in PowerShell
 
PowerShell v4 Desired State Configuration
PowerShell v4 Desired State ConfigurationPowerShell v4 Desired State Configuration
PowerShell v4 Desired State Configuration
 
Introduction to powershell
Introduction to powershellIntroduction to powershell
Introduction to powershell
 
PS scripting and modularization
PS scripting and modularizationPS scripting and modularization
PS scripting and modularization
 
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!
 
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - CertificateAdvanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
 
PowerShell 8tips
PowerShell 8tipsPowerShell 8tips
PowerShell 8tips
 
PowerShell crash course
PowerShell crash coursePowerShell crash course
PowerShell crash course
 
Best free tools for w d a
Best free tools for w d aBest free tools for w d a
Best free tools for w d a
 
PowerShell and WMI
PowerShell and WMIPowerShell and WMI
PowerShell and WMI
 
Best free tools for win database admin
Best free tools for win database adminBest free tools for win database admin
Best free tools for win database admin
 
PowerShell crashcourse
PowerShell crashcoursePowerShell crashcourse
PowerShell crashcourse
 
Meet Windows PowerShell
Meet Windows PowerShellMeet Windows PowerShell
Meet Windows PowerShell
 
From VB Script to PowerShell
From VB Script to PowerShellFrom VB Script to PowerShell
From VB Script to PowerShell
 
PS error handling and debugging
PS error handling and debuggingPS error handling and debugging
PS error handling and debugging
 

Similar to Basic PowerShell Toolmaking - Spiceworld 2016 session

Managing SharePoint Anywhere with Windows PowerShell
Managing SharePoint Anywhere with Windows PowerShellManaging SharePoint Anywhere with Windows PowerShell
Managing SharePoint Anywhere with Windows PowerShellRyan Dennis
 
Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionDave Diehl
 
My tryst with sourcecode review
My tryst with sourcecode reviewMy tryst with sourcecode review
My tryst with sourcecode reviewAnant Shrivastava
 
PowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue KidPowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue KidMatthew Johnson
 
Build a game with javascript (april 2017)
Build a game with javascript (april 2017)Build a game with javascript (april 2017)
Build a game with javascript (april 2017)Thinkful
 
If you want to automate, you learn to code
If you want to automate, you learn to codeIf you want to automate, you learn to code
If you want to automate, you learn to codeAlan Richardson
 
Kiran karnad rtc2014 ghdb-final
Kiran karnad rtc2014 ghdb-finalKiran karnad rtc2014 ghdb-final
Kiran karnad rtc2014 ghdb-finalRomania Testing
 
Design for scale
Design for scaleDesign for scale
Design for scaleDoug Lampe
 
Maintainable Machine Learning Products
Maintainable Machine Learning ProductsMaintainable Machine Learning Products
Maintainable Machine Learning ProductsAndrew Musselman
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Thinkful
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without InterferenceTony Tam
 
My first powershell script
My first powershell scriptMy first powershell script
My first powershell scriptDavid Cobb
 
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkins
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_WilkinsMongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkins
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkinskiwilkins
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
Under the Wire PowerShell workshop - BSides Augusta 2018
Under the Wire PowerShell workshop - BSides Augusta 2018Under the Wire PowerShell workshop - BSides Augusta 2018
Under the Wire PowerShell workshop - BSides Augusta 2018Fernando Tomlinson, CISSP, MBA
 
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & ProfitsWeaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & ProfitsHarsh Bothra
 
Intro to SharePoint + PowerShell
Intro to SharePoint + PowerShellIntro to SharePoint + PowerShell
Intro to SharePoint + PowerShellRyan Dennis
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyLeslie Doherty
 

Similar to Basic PowerShell Toolmaking - Spiceworld 2016 session (20)

Managing SharePoint Anywhere with Windows PowerShell
Managing SharePoint Anywhere with Windows PowerShellManaging SharePoint Anywhere with Windows PowerShell
Managing SharePoint Anywhere with Windows PowerShell
 
F8 tech talk_pinterest_v4
F8 tech talk_pinterest_v4F8 tech talk_pinterest_v4
F8 tech talk_pinterest_v4
 
Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood edition
 
My tryst with sourcecode review
My tryst with sourcecode reviewMy tryst with sourcecode review
My tryst with sourcecode review
 
PowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue KidPowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue Kid
 
Build a game with javascript (april 2017)
Build a game with javascript (april 2017)Build a game with javascript (april 2017)
Build a game with javascript (april 2017)
 
If you want to automate, you learn to code
If you want to automate, you learn to codeIf you want to automate, you learn to code
If you want to automate, you learn to code
 
Kiran karnad rtc2014 ghdb-final
Kiran karnad rtc2014 ghdb-finalKiran karnad rtc2014 ghdb-final
Kiran karnad rtc2014 ghdb-final
 
Design for scale
Design for scaleDesign for scale
Design for scale
 
Maintainable Machine Learning Products
Maintainable Machine Learning ProductsMaintainable Machine Learning Products
Maintainable Machine Learning Products
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
 
My first powershell script
My first powershell scriptMy first powershell script
My first powershell script
 
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkins
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_WilkinsMongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkins
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkins
 
Ranger BSides-FINAL
Ranger BSides-FINALRanger BSides-FINAL
Ranger BSides-FINAL
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
Under the Wire PowerShell workshop - BSides Augusta 2018
Under the Wire PowerShell workshop - BSides Augusta 2018Under the Wire PowerShell workshop - BSides Augusta 2018
Under the Wire PowerShell workshop - BSides Augusta 2018
 
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & ProfitsWeaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
 
Intro to SharePoint + PowerShell
Intro to SharePoint + PowerShellIntro to SharePoint + PowerShell
Intro to SharePoint + PowerShell
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 

Recently uploaded

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 

Recently uploaded (20)

Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 

Basic PowerShell Toolmaking - Spiceworld 2016 session

  • 1. Scripting as a Second Language Basic PowerShell Toolmaking
  • 2. Rob Dunn - @maximillianx • Lead Systems Administrator • IT Pro for 22 years • In the Spiceworks Community since 2007 • Pure Capsaicin since 2014
  • 3. Sponsored by Netwrix – www.netwrix.com Free products: • Change Notifier for AD, File Servers, Group Policy • Account Lockout Examiner Tool • Password Expiration Notifier • Effective Permissions Analyzer • And more! Flagship Product: • Audit (Active Directory, Azure AD, Oracle, SharePoint, VMware, O365, and more)
  • 4. #SPICEWORLD2016 • My take on the Difference Between a Script and a Tool • Toolmaking with a Tool (not just me), the ISE • The Genesis of the Tool • Demo! What We’ll Cover
  • 5. #SPICEWORLD2016 A simple script is a file containing a series of runtime instructions which can be executed repeatedly with a relatively specific focus which produces an expected outcome. Typically, the user running the script doesn’t have much, if any control over the output. What is a Simple Script?
  • 6. #SPICEWORLD2016 • Input • Functional • Output What is a Tool – Three Types
  • 7. #SPICEWORLD2016 What do We Use to Make Our PowerShell Scripts and Tools? [Demo] Use the right tool for the job! • Not NotePad or other text-based editors • Something that is “PowerShell” aware • This could be Visual Studio, VSCode, Sapien PowerShell Studio, or…the FREE Microsoft ISE. Advantages? 1. Easily execute single lines or sections of code 2. Tab completion of parameters, properties & methods 3. Debugging, error discovery, and syntax highlighting 4. Add-on support
  • 8. #SPICEWORLD2016 Toolmaking: My Thought Process Problem Level of Need Output Input
  • 9. #SPICEWORLD2016 Start with a bit of code that you’ve used once or twice and build your script around that. Today’s Method: Build From the “Inside Out”
  • 10.  Get-Command - Find that cmdlet you’re looking for  Get-Help (RTFM, right?! Don’t forget to ‘Update- Help’ as well!)  Get-Member - Find out the methods and properties associated with an object* * Pretty much everything in PowerShell is an object Quick review: Cmdlets you must know
  • 11. Quick review: What is a PowerShell Object? It’s a “thing” that represents something. You can also think of it like a row in a database table - with a twist Properties • $Friend.FirstName = Scott • $Friend.LastName = Brosnan • $Friend.Height = 1.7272 • $Friend.Funny = $True • $Friend.BurnsUnderAStreetL ampBecauseHeMustBeAVam pireNotATwilightVampireThe OtherKind= $True $Chair $Friend = Get-Friend | Where-Object FirstName –eq “Scott” $Friend.BeatBox(20) $Friend
  • 12. Methods • $Friend.Complain • $Friend.TellHorribleJoke • $Friend.TakeDownStorage Array • $Friend.BeatBox Quick review: What is a PowerShell Object? It’s a “thing” that represents something. You can also think of it like a row in a database table - with a twist $Chair $Friend = Get-Friend | Where-Object FirstName –eq “Scott” $Friend.BeatBox(20) $Friend
  • 13. Get Event Log Entries surrounding an item of interest The Scenario #SPICEWORLD2016
  • 14. #SPICEWORLD2016 The Problem A service account is experiencing a lockout in the middle of the night. IT needs to gather all the event log entries from the system log x minutes before and x minutes after the time of a specified event to see if there is “something else” going on.
  • 15. #SPICEWORLD2016 The IT manager has determined this problem occurs enough times to warrant a closer look at the symptoms by his junior staff; preferably by utilizing a consistent method when the problem recurs. The Level Of Need
  • 16. #SPICEWORLD2016 The IT manager would like to have all the surrounding event log entries in a view which can be browsed or exported to CSV for further analysis; potentially in Excel so they can compare them. The Output
  • 17. #SPICEWORLD2016 1. The date and time of Event we’re interested in 2. The range of minutes before and after the event to gather other possible interesting information. The Input (our Parameters)
  • 18. #SPICEWORLD2016 …find system event log items x minutes before and x minutes after event of interest occurs …output events to end user as objects BONUS: Can we get these items from ALL event logs? To use these parameters, our script needs to:
  • 20. #SPICEWORLD2016 • Comment-Based Help • Format your script – look like a Pro! • Make your scripts and functions single purpose, name them accordingly • Use Microsoft supported verbs to name your functions and scripts (Get- Verb) • Configure Execution Policy to run PS1 files (Set-ExecutionPolicy – ExecutionPolicy RemoteSigned, etc.) Best Practices
  • 21. #SPICEWORLD2016 1. Save your file as a .PS1 and share with your co-workers 2. Create a module (easier than it sounds) Share and Enjoy! I.e. Extra Credit 
  • 22. #SPICEWORLD2016 [Book] PowerShell in a Month of Lunches, Don Jones & Jeffery Hicks [Book] PowerShell ToolMaking in a Month of Lunches, Don Jones & Jeffery Hicks [Web] PowerShell 3.0 JumpStart, Microsoft Virtual Academy, Jason Helmick, Jeffery Snover* *heck, anything by Jeffery Snover, I mean, he invented it! Learning PowerShell?

Editor's Notes

  1. The Problem: What problem am I trying to solve? The Level of Need: Do I find that I need to solve this problem on more than a handful of occasions? Do I need to delegate this? The Output: What do I want to achieve upon script execution? Do I need to perform an action, review data, or notify someone? The Input: Given the requirements for output, what information do I need to supply to the script in order fulfill the above required output?
  2. Get-Command – just like it says, you can use this to “get” any command that Powershell has to offer. You can search based on a word, and wildcards are supported. Get-Command also works for all your Windows console commands, too! Get-Help – again, very descriptive here. You can use Get-Help in conjunction with any other cmdlet to discover what it does and how to use it. Get-Member – this one is different in that you “pipe” other cmdlets into this one to discover what kind of information the cmdlet presents and what kinds of actions you can take on the resultant objects the cmdlet returns. More on objects shortly!