Upload
michael-blumenthal
View
39
Download
1
Embed Size (px)
Citation preview
PowerShell Best Practices and ResourcesMichael BlumenthalPSC Group, LLC
Who is Michael Blumenthal?• Technical Solution Evangelist at PSC Group
• Office 365 MVP
• Dev/ITPro Mix
• In IT Consulting since 1995
• PowerShelling since 2007
• Anyone used PowerShell before?
• Who’s done scripting before? Windows? Unix?
• Developer or Administrator?
This is about you
Best Practices
Use FunctionsFunction global:Do-Something(){}
Function global:Do-Something($someParameter){}
Function global:Do-Something{param ([type]$someParameter=$(“Default
Expression”))}
Follow the Naming Convention!
Verb-Noun
• 98 Verbs
Comment your functions<#.SYNOPSIS –a brief explanation of what the script or function does..DESCRIPTION – a more detailed explanation of what the script or function does..PARAMETER name – an explanation of a specific parameter. Replace name with the parameter name. You can have one of these sections for each parameter the script or function uses..EXAMPLE – an example of how to use the script or function. You can have multiple .EXAMPLE sections if you want to provide more than one example..NOTES – any miscellaneous notes on using the script or function..LINK – a cross-reference to another help topic; you can have more than one of these. If you include a URL beginning with http:// or https://, the shell will open that URL when the Help command’s –online parameter is used.
#>
Search for Commands
Refresh the command list
Actions you can take
Self Announcing Functions
…
Source Code Control
•Always read scripts before running them
More Good Ideas
•Always read scripts before running them•Make yours safe when others don’t
More Good Ideas
•Always read scripts before running them•Make yours safe when others don’t•Check for valid parameter values • get-help about_Functions_Advanced_Parameters
More Good Ideas
•Always read scripts before running them•Make yours safe when others don’t•Check for valid parameter values • get-help about_Functions_Advanced_Parameters •Do error handling • get-help about_Try_Catch_Finally• get-help about_CommonParameters • -ErrorAction and -ErrorVariable
More Good Ideas
More Resources
JEFF HICKS
Find Chris JohnsonMVP
Lounge
Thursday, 9/29
4pm-5pm
http://bit.ly/pscmeComplete the form and I will send you my Comment Block template.
Join the conversation on the Microsoft Tech CommunityTHR2078 – Master PowerShell Basics: Resources and Best Practices
http://bit.ly/THR2078
From your PC or Tablet visit MyIgnite at http://myignite.microsoft.com
From your phone download and use the Ignite Mobile App by scanning the QR code above or visiting https://aka.ms/ignite.mobileapp
Please evaluate this sessionYour feedback is important to us!
Write Better Scripts starting today!
In Review…
© 2016 Microsoft Corporation. All rights reserved.