PowerShell Best Practices and Resources
-
Upload
michael-blumenthal -
Category
Technology
-
view
37 -
download
1
Transcript of PowerShell Best Practices and Resources
![Page 1: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/1.jpg)
![Page 2: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/2.jpg)
PowerShell Best Practices and ResourcesMichael BlumenthalPSC Group, LLC
![Page 3: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/3.jpg)
Who is Michael Blumenthal?• Technical Solution Evangelist at PSC Group
• Office 365 MVP
• Dev/ITPro Mix
• In IT Consulting since 1995
• PowerShelling since 2007
![Page 4: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/4.jpg)
• Anyone used PowerShell before?
• Who’s done scripting before? Windows? Unix?
• Developer or Administrator?
This is about you
![Page 5: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/5.jpg)
Best Practices
![Page 6: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/6.jpg)
Use FunctionsFunction global:Do-Something(){}
Function global:Do-Something($someParameter){}
Function global:Do-Something{param ([type]$someParameter=$(“Default
Expression”))}
![Page 7: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/7.jpg)
Follow the Naming Convention!
Verb-Noun
• 98 Verbs
![Page 8: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/8.jpg)
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.
#>
![Page 9: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/9.jpg)
Search for Commands
Refresh the command list
Actions you can take
![Page 10: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/10.jpg)
Self Announcing Functions
…
![Page 11: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/11.jpg)
Source Code Control
![Page 12: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/12.jpg)
•Always read scripts before running them
More Good Ideas
![Page 13: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/13.jpg)
•Always read scripts before running them•Make yours safe when others don’t
More Good Ideas
![Page 14: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/14.jpg)
•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
![Page 15: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/15.jpg)
•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
![Page 16: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/16.jpg)
More Resources
![Page 18: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/18.jpg)
![Page 19: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/19.jpg)
![Page 20: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/20.jpg)
![Page 21: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/21.jpg)
JEFF HICKS
![Page 22: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/22.jpg)
![Page 23: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/23.jpg)
Find Chris JohnsonMVP
Lounge
Thursday, 9/29
4pm-5pm
![Page 24: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/24.jpg)
http://bit.ly/pscmeComplete the form and I will send you my Comment Block template.
![Page 25: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/25.jpg)
Join the conversation on the Microsoft Tech CommunityTHR2078 – Master PowerShell Basics: Resources and Best Practices
http://bit.ly/THR2078
![Page 26: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/26.jpg)
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!
![Page 27: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/27.jpg)
Write Better Scripts starting today!
In Review…
![Page 28: PowerShell Best Practices and Resources](https://reader036.fdocuments.us/reader036/viewer/2022062316/5878166d1a28aba12d8b4783/html5/thumbnails/28.jpg)
© 2016 Microsoft Corporation. All rights reserved.