SlideShare une entreprise Scribd logo
1  sur  57
Professional Help for
PowerShell Modules
June Blender
Technology Evangelist
SAPIEN Technologies, Inc.
Windows PowerShell MVP
juneb@sapien.com
@juneb_get_help
Tested Versions
The information and code used in this presentation were
tested with the following system attributes.
• Windows 7 Pro RTM, Windows Server 2012 R2 Ultimate,
Microsoft Windows 10 Pro 10.0.10586 (x64), Windows
Server 2012 R2 (x64), Microsoft Window 10 Home Insider
Preview 10.0.14279
• Windows PowerShell 3.0, 4.0, 5.0.10586.122,
5.0.14279.1000
Contact: June Blender, @juneb_get_help, juneb@sapien.com
Slides and code for all help talks:
PowerShell Help Deep Dive
(GitHub)
https://github.com/juneb/PowerShellHelpDeepDive
• Why write help -- for modules?
• Rules & Syntax
• Comment-based help v. XML help
• Improve the content
• Write great cmdlet help - Use checklists
• Writing great About Help
• Re-purposing Github wiki
Agenda
I'm too busy to write help...
... shifting the
burden
Inefficient
Undocumented tool -EQ Unautomated process
Inefficient
Why write help for a module?
• Likely to share it
• Like to keep it (and need to maintain it)
• More complex than a script
• More valuable
How is help different for a module
• Examples are intertwined
• About topic (at least one; typically more)
• Benefit from "Get-Help -Online"
Don't write help for your own module
• Find a writer
• Get a buddy
• Immersed in the implementation
• Need a beginner perspective focused
on the user experience
Benefits to the Author of Writing
Help
• It makes you a better blogger and
instructor
• Writing help as a code spec
• Examples -EQ Tests
"Help-Driven Development"
Help as a code specification
• Description: Describe the UI.
• Examples:
– Which parameters you need
– Recognizable parameter names
– Parameter attributes
– Parameter combinations -> parameter sets
• Expected outcomes for testing
• Inputs: Coordinate types with other cmdlets
• Outputs: Define return values
Advanced Help for Advanced Functions #PSBlogWeek
"Help-Driven Development"
Help Examples as a Pester test
spec
• Help examples are user contract
• Supports behavior-driven development
• Supports "white box" testing
• Test input possibilities
• Test piping between cmdlets
https://github.com/juneb/PesterTDD
Mechanics:
A few hints about help syntax...
Comment-based help v. XML help
XML Help Comment-Based Help
CIM Commands x
Cmdlets x
Functions x x
Providers x
Scripts x
Workflows x x (4.0+)
Comment-Based Help
Costs/Benefits
Benefits
• Easy
• Help always matches code
Costs
• Not supported for cmdlets, providers, CIM commands
• No updatable help
• No multi-language support
• FRAGILE !
What can go wrong with comment-based help?
• One keyword typo, all ignored
• One misplaced value, all ignored
• More than one empty line between help and
function
Troubleshooting Comment-Based Help
XML Help
Costs / Benefits
Benefits
• All command types (cmdlets/functions/workflows/CIM
commands)
• Updatable Help
• Multiple spoken languages
• Robust; error-safe
• Separates help from code (Github)
Costs
• PSMAML XML or Markdown file -> XML
• Help might not match code
What can go wrong with XML help?
• Naming XML help files
• Missing #.ExternalHelp keyword in functions
(3.0 file names)
• Comment-based help takes precedence over XML help
• # .ExternalHelp keyword takes precedence over CBH
• Command not found (Get-Help uses Get-Command)
• Invalid schema (rare; pretty forgiving)
Writing XML Help for Advanced Functions
Naming XML Help Files
Cmdlets, CIM commands, Workflows
• PowerShell 3.0
<CmdletDefinitionFile>-help.xml
MSFT_NetQosPolicy.cdxml-help.xml
Microsoft.PowerShell.Archive.dll-help.xml
• PowerShell 4.0 (5.0 script modules)
<ModuleName>-help.xml
Microsoft.PowerShell.ODataUtils-help.xml
Writing XML Help for Advanced Functions
Naming XML Help Files
Functions
• PowerShell 3.0
No filename requirements.
Requires # .ExternalHelp comment keyword
function Get-Widget {
# .ExternalHelp MyModule.psm1-help.xml
}
• PowerShell 4.0
(Works for script modules beginning in 5.0)
<ModuleName>-help.xml
Does not require #.ExternalHelp comment
Writing XML Help for Advanced Functions
.ExternalHelp keyword
– Associates a function with an XML help file
# .ExternalHelp <filename>-help.xml
function MyFunction {}
– 3.0: Required for functions
– 4.0: Required for script modules
Optional in manifest modules (value ignored)
– 5.0: Required only for 3.0 XML help file names
<ModuleName>.psm1-help.xml
Writing XML Help for Advanced Functions
Where do I put help files?
XML, About
• In language-specific subdirectory of a module
directory, e.g. en-US
• In the root of the module directory
• In the subdirectory of the module directory
(should work...)
Writing XML Help for Advanced Functions
It's all about the content!
PowerShell Help Deep Dive (GitHub)
Code comments v. help
"I have code comments. Isn't that enough?"
"I'll just put my code comments in comment-based
help."
What's different? They're opposites!
• Audience
• Perspective
• Subject
Easy (help) writing rules
• Use clear, simple language
– Get, not "retrieve"
– Use, not "utilize"
– Change, not "modify"
– Be careful with "remove" -- is this
permanent? Delete?
• Use active voice:
– Passive: The objects can be exported ...
– Active: You can export the objects ...
To export the objects, <do
this>.
Easy (help) writing rules
• Give instructions in the order that the
user needs them.
– Click Run in the Things section of the Home
tab.
– Click the Home tab and, in the Things
section, click Run.
Easy (help) writing rules
• Task first, then instructions:
(Start with "To")
– Use the Format parameter to format the
date.
– To format the date, use the Format
parameter.
– Using the Credential parameter will help
you to avoid Access Denied errors.
– To avoid Access Denied errors, use the
Credential parameter.
Define technical terms
Reuse content
• You don't have to be original. Reusing is
efficient.
• Reuse parameter descriptions!
• Be sure to cite and credit the original author
with a link.
Write, use, and share checklists
• Checklists for Authoring PowerShell Help on
GitHub
http://github.com/juneb/PowerShellHelpDeepDiv
e
Synopsis Checklist "Elevator
speech"
Will this cmdlet solve my problem?
• Identify the technology (What kind of disk?)
• Describe the action and outcome
• Generic v. specific
(Removes all events from the session.)
Checklists for Authoring PowerShell Help
Use Synopsis Checklist:
Invoke-Pester (3.4.0)
• Identify the technology (What kind of disk?)
Testing PowerShell code
• Be specific about the action and outcome.
Runs *.Tests.ps1 files. Recursive.
• If it's generic, say so.
All by default; parameters filter the tests
Result:
Runs all or selected Pester tests (*.Tests.ps1) in
a directory and its subdirectories.
About Help
Without it, your module is
a confusing collection of
unrelated commands.
Where do I start?
About Help file
about_<Topic>.help.txt
• Module directory
• In a language-specific
subdirectory
about_Topic Template : 1000-1500
words
• TOPIC Line 1, column 1
about_<Name> Line 2, column 5
Line 3 (blank)
• SHORT DESCRIPTION Line 4, column 1
<Description> Line 5, column 5
• LONG DESCRIPTION
• <SUBTOPICS>
• EXAMPLES
• NOTE:
• TROUBLESHOOTING NOTE: #Known bugs
• SEE ALSO #Add URL of your Github wiki
• KEYWORDS
* UTF-8 encoding
Maybe I'll fold laundry instead.
About Help Checklist
"It tells the story of your module." -- Chrissy
LeMaire
• What problem does the module solve?
• How do I use the cmdlets together to solve it?
• Meta-cmdlet help
• In what order do I use the commands?
• Is one a prerequisite?
• Is one designed to pipe to another?
• Examples+++
about_Pester
Short Description
• 1-2 paragraphs that describe the concept.
• "Will this module solve my problem?"
• In which domain or technology does it work?
• System requirements
• If the topic is long, list the subtitles in this
section, like a table of contents.
Short Description
Long Description
Start with an outline
• Brainstorm your subtopics.
• Arrange subtopics in an order useful to the
reader.
– Simple to complex
– Basic to advanced
– Required order: Get/Set
• Write a sentence or paragraph for every
subtopic.
• Reorder subtopics. Best order for the reader.
• Have a friend read it.
Long description: Typical ordered
outline
• Purpose / Solution / Task
• Basic example
• Cmdlet/Function list
• How-to sections
(New/Get/Set/Save)
• Examples (try it)
• Background info
about_Aliases
about_Pester : Long description
outline
• Problem statement: Unit/integration testing
• Language basics, DSL (describe, it, should
be)
• How-to: Create, Write, Run
• How to save; default output is Write-Host
• Example. Try it.
• Real-world examples (from original file)
about_Pester : Long description final
• What does Pester test (concepts)
• The Pester language (basics + example)
• How to Create a Pester Test
• How to Run a Pester Test
• Example
• Pester Test Output (Write-Host v. custom
object)
• Real-world examples (Pester's own tests)
Can I use my GitHub wiki?
YES!!
It's online help!
Supporting "Get-Help -Online"
PS C:>Get-Help Get-Widget -Online
Not for About help
Supporting Online Help (MSDN)
Two ways to specify an online help URI for
a command:
-- First related link in help topic (preceden
-- HelpUri attribute
Supporting Online Help
First related link in help topic
-- Value must begin with 'http' or 'https'
Supporting Online Help (MSDN)
Supporting Online Help
First related link in help topic
-- Value must begin with 'http' or 'https'
Supporting Online Help (MSDN)
.ExternalHelp takes precedence
over other comment-based help keywords
Supporting Online Help
Function: HelpUri attribute of CmdletBinding
C# Cmdlets: HelpUri attribute of Cmdlet class
CIM commands: HelpUri attribute of CmdletMetadata ele
Supporting Online Help (MSDN)
Online Help : About_help is not
supported
SEE ALSO
Pester Wiki (it's excellent!)
Supporting Online Help (MSDN)
Help for DSC, Classes : About topics
about_WineGlass.help.txt
References
Troubleshooting Comment-Based Help
Writing XML Help for Advanced Functions
Naming Help Files (PS 3.0 only; not updated for 4.0+)
Checklists for Authoring PowerShell Help
How to Write Great Help Examples
Supporting Online Help (MSDN)
Slides and code for all help talks: PowerShell Help Deep Dive (GitHub)
Use help as a code spec: Advanced Help for Advanced Functions
Use help examples as a test spec: https://github.com/juneb/PesterTDD
Professional Help for
PowerShell Modules
June Blender
Technology Evangelist
SAPIEN Technologies, Inc.
Windows PowerShell MVP
juneb@sapien.com
@juneb_get_help

Contenu connexe

Tendances

Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellBoulos Dib
 
Get-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for EvilGet-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for Eviljaredhaight
 
Introduction to Powershell Version 5
Introduction to Powershell Version 5Introduction to Powershell Version 5
Introduction to Powershell Version 5Nishtha Kesarwani
 
PowerShell Technical Overview
PowerShell Technical OverviewPowerShell Technical Overview
PowerShell Technical Overviewallandcp
 
Pragmatic plone projects
Pragmatic plone projectsPragmatic plone projects
Pragmatic plone projectsAndreas Jung
 
PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2Bryan Cafferky
 
How to do everything with PowerShell
How to do everything with PowerShellHow to do everything with PowerShell
How to do everything with PowerShellJuan Carlos Gonzalez
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring ClojurescriptLuke Donnet
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
 
Zend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applicationsZend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applicationsEnrico Zimuel
 
Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Puppet
 
Demystifying Object-Oriented Programming - ZendCon 2016
Demystifying Object-Oriented Programming - ZendCon 2016Demystifying Object-Oriented Programming - ZendCon 2016
Demystifying Object-Oriented Programming - ZendCon 2016Alena Holligan
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpJavascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpAll Things Open
 
Workshop: PowerShell for Penetration Testers
Workshop: PowerShell for Penetration TestersWorkshop: PowerShell for Penetration Testers
Workshop: PowerShell for Penetration TestersNikhil Mittal
 
PowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationPowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationWill Schroeder
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and DesktopElizabeth Smith
 

Tendances (20)

Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Get-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for EvilGet-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for Evil
 
Introduction to Powershell Version 5
Introduction to Powershell Version 5Introduction to Powershell Version 5
Introduction to Powershell Version 5
 
PowerShell Technical Overview
PowerShell Technical OverviewPowerShell Technical Overview
PowerShell Technical Overview
 
Windows PowerShell
Windows PowerShellWindows PowerShell
Windows PowerShell
 
Pragmatic plone projects
Pragmatic plone projectsPragmatic plone projects
Pragmatic plone projects
 
PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2
 
How to do everything with PowerShell
How to do everything with PowerShellHow to do everything with PowerShell
How to do everything with PowerShell
 
Network programming
Network programmingNetwork programming
Network programming
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
Zend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applicationsZend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applications
 
Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Doing It Wrong with Puppet -
Doing It Wrong with Puppet -
 
Demystifying Object-Oriented Programming - ZendCon 2016
Demystifying Object-Oriented Programming - ZendCon 2016Demystifying Object-Oriented Programming - ZendCon 2016
Demystifying Object-Oriented Programming - ZendCon 2016
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpJavascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and Gulp
 
Workshop: PowerShell for Penetration Testers
Workshop: PowerShell for Penetration TestersWorkshop: PowerShell for Penetration Testers
Workshop: PowerShell for Penetration Testers
 
PowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationPowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege Escalation
 
Pycon - Python for ethical hackers
Pycon - Python for ethical hackers Pycon - Python for ethical hackers
Pycon - Python for ethical hackers
 
Migration from ASP to ASP.NET
Migration from ASP to ASP.NETMigration from ASP to ASP.NET
Migration from ASP to ASP.NET
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 

Similaire à Professional Help for PowerShell Modules

Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionDave Diehl
 
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 Dutyreedmaniac
 
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
 
PowerShell for Penetration Testers
PowerShell for Penetration TestersPowerShell for Penetration Testers
PowerShell for Penetration TestersNikhil Mittal
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!Alessandro Giorgetti
 
DSL's with Groovy
DSL's with GroovyDSL's with Groovy
DSL's with Groovypaulbowler
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Bachkoutou Toutou
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013Iván Montes
 
PowerShell 101 - What is it and Why should YOU Care!
PowerShell 101 - What is it and Why should YOU Care!PowerShell 101 - What is it and Why should YOU Care!
PowerShell 101 - What is it and Why should YOU Care!Thomas Lee
 
PowerShell 101
PowerShell 101PowerShell 101
PowerShell 101Thomas Lee
 
5 hs mpostcustomizationrenefonseca
5 hs mpostcustomizationrenefonseca5 hs mpostcustomizationrenefonseca
5 hs mpostcustomizationrenefonsecassuserfadb24
 
Introducing PS>Attack: An offensive PowerShell toolkit
Introducing PS>Attack: An offensive PowerShell toolkitIntroducing PS>Attack: An offensive PowerShell toolkit
Introducing PS>Attack: An offensive PowerShell toolkitjaredhaight
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Andrei KUCHARAVY
 

Similaire à Professional Help for PowerShell Modules (20)

Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood edition
 
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
 
presentation
presentationpresentation
presentation
 
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
 
presentation
presentationpresentation
presentation
 
PowerShell for Penetration Testers
PowerShell for Penetration TestersPowerShell for Penetration Testers
PowerShell for Penetration Testers
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!
 
DSL's with Groovy
DSL's with GroovyDSL's with Groovy
DSL's with Groovy
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011
 
Continuous feature-development
Continuous feature-developmentContinuous feature-development
Continuous feature-development
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013
 
PowerShell 101 - What is it and Why should YOU Care!
PowerShell 101 - What is it and Why should YOU Care!PowerShell 101 - What is it and Why should YOU Care!
PowerShell 101 - What is it and Why should YOU Care!
 
PowerShell 101
PowerShell 101PowerShell 101
PowerShell 101
 
5 hs mpostcustomizationrenefonseca
5 hs mpostcustomizationrenefonseca5 hs mpostcustomizationrenefonseca
5 hs mpostcustomizationrenefonseca
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Introducing PS>Attack: An offensive PowerShell toolkit
Introducing PS>Attack: An offensive PowerShell toolkitIntroducing PS>Attack: An offensive PowerShell toolkit
Introducing PS>Attack: An offensive PowerShell toolkit
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1
 
Modern Python Testing
Modern Python TestingModern Python Testing
Modern Python Testing
 

Dernier

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Dernier (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Professional Help for PowerShell Modules

  • 1. Professional Help for PowerShell Modules June Blender Technology Evangelist SAPIEN Technologies, Inc. Windows PowerShell MVP juneb@sapien.com @juneb_get_help
  • 2. Tested Versions The information and code used in this presentation were tested with the following system attributes. • Windows 7 Pro RTM, Windows Server 2012 R2 Ultimate, Microsoft Windows 10 Pro 10.0.10586 (x64), Windows Server 2012 R2 (x64), Microsoft Window 10 Home Insider Preview 10.0.14279 • Windows PowerShell 3.0, 4.0, 5.0.10586.122, 5.0.14279.1000 Contact: June Blender, @juneb_get_help, juneb@sapien.com
  • 3. Slides and code for all help talks: PowerShell Help Deep Dive (GitHub) https://github.com/juneb/PowerShellHelpDeepDive
  • 4. • Why write help -- for modules? • Rules & Syntax • Comment-based help v. XML help • Improve the content • Write great cmdlet help - Use checklists • Writing great About Help • Re-purposing Github wiki Agenda
  • 5. I'm too busy to write help... ... shifting the burden Inefficient
  • 6. Undocumented tool -EQ Unautomated process Inefficient
  • 7. Why write help for a module? • Likely to share it • Like to keep it (and need to maintain it) • More complex than a script • More valuable
  • 8. How is help different for a module • Examples are intertwined • About topic (at least one; typically more) • Benefit from "Get-Help -Online"
  • 9. Don't write help for your own module • Find a writer • Get a buddy • Immersed in the implementation • Need a beginner perspective focused on the user experience
  • 10. Benefits to the Author of Writing Help • It makes you a better blogger and instructor • Writing help as a code spec • Examples -EQ Tests
  • 11. "Help-Driven Development" Help as a code specification • Description: Describe the UI. • Examples: – Which parameters you need – Recognizable parameter names – Parameter attributes – Parameter combinations -> parameter sets • Expected outcomes for testing • Inputs: Coordinate types with other cmdlets • Outputs: Define return values Advanced Help for Advanced Functions #PSBlogWeek
  • 12. "Help-Driven Development" Help Examples as a Pester test spec • Help examples are user contract • Supports behavior-driven development • Supports "white box" testing • Test input possibilities • Test piping between cmdlets https://github.com/juneb/PesterTDD
  • 13. Mechanics: A few hints about help syntax...
  • 14. Comment-based help v. XML help XML Help Comment-Based Help CIM Commands x Cmdlets x Functions x x Providers x Scripts x Workflows x x (4.0+)
  • 15. Comment-Based Help Costs/Benefits Benefits • Easy • Help always matches code Costs • Not supported for cmdlets, providers, CIM commands • No updatable help • No multi-language support • FRAGILE !
  • 16. What can go wrong with comment-based help? • One keyword typo, all ignored • One misplaced value, all ignored • More than one empty line between help and function Troubleshooting Comment-Based Help
  • 17. XML Help Costs / Benefits Benefits • All command types (cmdlets/functions/workflows/CIM commands) • Updatable Help • Multiple spoken languages • Robust; error-safe • Separates help from code (Github) Costs • PSMAML XML or Markdown file -> XML • Help might not match code
  • 18. What can go wrong with XML help? • Naming XML help files • Missing #.ExternalHelp keyword in functions (3.0 file names) • Comment-based help takes precedence over XML help • # .ExternalHelp keyword takes precedence over CBH • Command not found (Get-Help uses Get-Command) • Invalid schema (rare; pretty forgiving) Writing XML Help for Advanced Functions
  • 19. Naming XML Help Files Cmdlets, CIM commands, Workflows • PowerShell 3.0 <CmdletDefinitionFile>-help.xml MSFT_NetQosPolicy.cdxml-help.xml Microsoft.PowerShell.Archive.dll-help.xml • PowerShell 4.0 (5.0 script modules) <ModuleName>-help.xml Microsoft.PowerShell.ODataUtils-help.xml Writing XML Help for Advanced Functions
  • 20. Naming XML Help Files Functions • PowerShell 3.0 No filename requirements. Requires # .ExternalHelp comment keyword function Get-Widget { # .ExternalHelp MyModule.psm1-help.xml } • PowerShell 4.0 (Works for script modules beginning in 5.0) <ModuleName>-help.xml Does not require #.ExternalHelp comment Writing XML Help for Advanced Functions
  • 21. .ExternalHelp keyword – Associates a function with an XML help file # .ExternalHelp <filename>-help.xml function MyFunction {} – 3.0: Required for functions – 4.0: Required for script modules Optional in manifest modules (value ignored) – 5.0: Required only for 3.0 XML help file names <ModuleName>.psm1-help.xml Writing XML Help for Advanced Functions
  • 22. Where do I put help files? XML, About • In language-specific subdirectory of a module directory, e.g. en-US • In the root of the module directory • In the subdirectory of the module directory (should work...) Writing XML Help for Advanced Functions
  • 23. It's all about the content! PowerShell Help Deep Dive (GitHub)
  • 24. Code comments v. help "I have code comments. Isn't that enough?" "I'll just put my code comments in comment-based help." What's different? They're opposites! • Audience • Perspective • Subject
  • 25. Easy (help) writing rules • Use clear, simple language – Get, not "retrieve" – Use, not "utilize" – Change, not "modify" – Be careful with "remove" -- is this permanent? Delete? • Use active voice: – Passive: The objects can be exported ... – Active: You can export the objects ... To export the objects, <do this>.
  • 26. Easy (help) writing rules • Give instructions in the order that the user needs them. – Click Run in the Things section of the Home tab. – Click the Home tab and, in the Things section, click Run.
  • 27. Easy (help) writing rules • Task first, then instructions: (Start with "To") – Use the Format parameter to format the date. – To format the date, use the Format parameter. – Using the Credential parameter will help you to avoid Access Denied errors. – To avoid Access Denied errors, use the Credential parameter.
  • 29. Reuse content • You don't have to be original. Reusing is efficient. • Reuse parameter descriptions! • Be sure to cite and credit the original author with a link.
  • 30. Write, use, and share checklists • Checklists for Authoring PowerShell Help on GitHub http://github.com/juneb/PowerShellHelpDeepDiv e
  • 31. Synopsis Checklist "Elevator speech" Will this cmdlet solve my problem? • Identify the technology (What kind of disk?) • Describe the action and outcome • Generic v. specific (Removes all events from the session.) Checklists for Authoring PowerShell Help
  • 32. Use Synopsis Checklist: Invoke-Pester (3.4.0) • Identify the technology (What kind of disk?) Testing PowerShell code • Be specific about the action and outcome. Runs *.Tests.ps1 files. Recursive. • If it's generic, say so. All by default; parameters filter the tests Result: Runs all or selected Pester tests (*.Tests.ps1) in a directory and its subdirectories.
  • 33. About Help Without it, your module is a confusing collection of unrelated commands.
  • 34. Where do I start?
  • 35. About Help file about_<Topic>.help.txt • Module directory • In a language-specific subdirectory
  • 36. about_Topic Template : 1000-1500 words • TOPIC Line 1, column 1 about_<Name> Line 2, column 5 Line 3 (blank) • SHORT DESCRIPTION Line 4, column 1 <Description> Line 5, column 5 • LONG DESCRIPTION • <SUBTOPICS> • EXAMPLES • NOTE: • TROUBLESHOOTING NOTE: #Known bugs • SEE ALSO #Add URL of your Github wiki • KEYWORDS * UTF-8 encoding
  • 37. Maybe I'll fold laundry instead.
  • 38.
  • 39. About Help Checklist "It tells the story of your module." -- Chrissy LeMaire • What problem does the module solve? • How do I use the cmdlets together to solve it? • Meta-cmdlet help • In what order do I use the commands? • Is one a prerequisite? • Is one designed to pipe to another? • Examples+++
  • 41. Short Description • 1-2 paragraphs that describe the concept. • "Will this module solve my problem?" • In which domain or technology does it work? • System requirements • If the topic is long, list the subtitles in this section, like a table of contents.
  • 43. Long Description Start with an outline • Brainstorm your subtopics. • Arrange subtopics in an order useful to the reader. – Simple to complex – Basic to advanced – Required order: Get/Set • Write a sentence or paragraph for every subtopic. • Reorder subtopics. Best order for the reader. • Have a friend read it.
  • 44. Long description: Typical ordered outline • Purpose / Solution / Task • Basic example • Cmdlet/Function list • How-to sections (New/Get/Set/Save) • Examples (try it) • Background info
  • 46. about_Pester : Long description outline • Problem statement: Unit/integration testing • Language basics, DSL (describe, it, should be) • How-to: Create, Write, Run • How to save; default output is Write-Host • Example. Try it. • Real-world examples (from original file)
  • 47. about_Pester : Long description final • What does Pester test (concepts) • The Pester language (basics + example) • How to Create a Pester Test • How to Run a Pester Test • Example • Pester Test Output (Write-Host v. custom object) • Real-world examples (Pester's own tests)
  • 48. Can I use my GitHub wiki? YES!! It's online help!
  • 49. Supporting "Get-Help -Online" PS C:>Get-Help Get-Widget -Online Not for About help Supporting Online Help (MSDN) Two ways to specify an online help URI for a command: -- First related link in help topic (preceden -- HelpUri attribute
  • 50. Supporting Online Help First related link in help topic -- Value must begin with 'http' or 'https' Supporting Online Help (MSDN)
  • 51. Supporting Online Help First related link in help topic -- Value must begin with 'http' or 'https' Supporting Online Help (MSDN)
  • 52. .ExternalHelp takes precedence over other comment-based help keywords
  • 53. Supporting Online Help Function: HelpUri attribute of CmdletBinding C# Cmdlets: HelpUri attribute of Cmdlet class CIM commands: HelpUri attribute of CmdletMetadata ele Supporting Online Help (MSDN)
  • 54. Online Help : About_help is not supported SEE ALSO Pester Wiki (it's excellent!) Supporting Online Help (MSDN)
  • 55. Help for DSC, Classes : About topics about_WineGlass.help.txt
  • 56. References Troubleshooting Comment-Based Help Writing XML Help for Advanced Functions Naming Help Files (PS 3.0 only; not updated for 4.0+) Checklists for Authoring PowerShell Help How to Write Great Help Examples Supporting Online Help (MSDN) Slides and code for all help talks: PowerShell Help Deep Dive (GitHub) Use help as a code spec: Advanced Help for Advanced Functions Use help examples as a test spec: https://github.com/juneb/PesterTDD
  • 57. Professional Help for PowerShell Modules June Blender Technology Evangelist SAPIEN Technologies, Inc. Windows PowerShell MVP juneb@sapien.com @juneb_get_help

Notes de l'éditeur

  1. Direct positive correlation
  2. Practice in explaining concepts and writing instructions; People who write good help are good instructors; People who are good instructors write good help
  3. Force you to confront issues that you'd rather forget; but that users will encounter
  4. What if you hedge your bets and use both. In a script module with correctly-formatted .EXTERNALHELP, an error in comment-based help -> autogenerated help
  5. What if you hedge your bets and use both. In a script module with correctly-formatted .EXTERNALHELP, an error in comment-based help -> autogenerated help
  6. If the credential changes, an error occurs. If a user name is entered, a password prompt is displayed.
  7. PowerForensics: Invoke-ForensicDD, Get-ForensicBootSector (master boot record v. guid partition table)