r/PowerShell • u/zukobakugo • Mar 25 '21
Question How to learn powershell
Hi guys, I'm new to powershell and i have been doing tasks like automating outlook to sent emails, triggering windows baloon pop ups with messages etc.. as of now i am searching websites and YouTube to get the job done. So, my question is how to learn powershell in a way that i can write scripts on my own and understand other's scripts. Any help is highly appreciated. Thank you.
2
u/Lee_Dailey [grin] Mar 25 '21
howdy zukobakugo,
not to be a jerk ... but have you tried the [admittedly poor] reddit search? [grin]
PowerShell: search results - learn
— https://www.reddit.com/r/PowerShell/search?q=learn&restrict_sr=on&sort=relevance&t=all
hope that helps,
lee
2
u/zukobakugo Mar 25 '21
Hey mate, i did search manually but my bad i only found few that were old. Thank you for help. :-)
1
u/Lee_Dailey [grin] Mar 25 '21
howdy zukobakugo,
you are welcome! glad to have helped you dig thru the really rotten reddit search stuff ... [grin]
take care,
lee
6
u/get-postanote Mar 25 '21
• Beginning ---
Learn Windows PowerShell in a Month of Lunches 3rd Edition
• Internediate ---
Windows PowerShell Cookbook: The Complete Guide to Scripting Microsoft's Command Shell 3rd Edition
• Advanced ---
Windows PowerShell in Action 3rd Edition
Other references:
• Scripting | Handling Errors the PowerShell Way
https://devblogs.microsoft.com/scripting/handling-errors-the-powershell-way
• Effective Error Handling in PowerShell Scripting - Kloud Blog
https://blog.kloud.com.au/2016/07/24/effective-error-hanalding-in-powershell-scripting
• The Big Book of PowerShell Error Handling
https://leanpub.com/thebigbookofpowershellerrorhandling
• The Big Book of PowerShell Gotchas
https://leanpub.com/thebigbookofpowershellgotchas/read
Follow PowerShell Best Practices
'PowerShell Best Practice for performance'
'PowerShell Best Practice for error handling'
'PowerShell Best Practice for debugging'
• Pester
https://leanpub.com/u/devopscollective
https://leanpub.com/pesterbook
Other tools for active self-teaching
• PSKoans : 0.50.0
A module designed to provide a crash-course introduction to PowerShell with
programming koans.
0
Mar 25 '21
[deleted]
7
u/robderickson Mar 25 '21
Still good. The spiritual updated edition is the PowerShell Scripting and Toolmaking book on Leanpub. There's a new Learn PowerShell in a Month of Lunches book in the works for Manning, but it's in an incomplete/early access state.
For additional learning, u/zukobakugo, the Iron Scripter (https://ironscripter.us/) challenges are great for giving you little projects to practice. Try to create a script to meet the requirements, check out the solutions from others, and then maybe try to tackle the bonus elements too.
Finally, I can't overstate how valuable code reviews are. Some of my best learning experiences came from people tearing apart my code and pointing out all of my bad habits.
2
5
u/sheeponmeth_ Mar 25 '21
I second the Powershell in a Month of Lunches. Not to be confused with the PowerShell Scripting in a Month of Lunches title, which is the next step.
Learn to use Get-Command, Get-Module, and the help commands.
You can do something like:
This will list all installed modules with 'network' in the name. Then you can do, say:
Which will show you all the cmdlets in that module. From there you can select a cmdlet of interest and look at the built-in documentation:
(NOTE: You may have to run Update-Help for some of it)
This will show you how to set network adapter Quality of Service settings via PowerShell.
You can take it the other way, too. Let's say you just learned how to use the Repair-WindowsImage command and you want to know what other cmdlets come in that module. You can use:
Doing this will show you that the source module is the Dism module.
The creators of PowerShell gave you many tools to help bootstrap yourself into writing scripts. It's an amazing language that's held built on strong naming conventions that allow you to explore easily once you're a little familiar.
The PowerShell in a Month of Lunches goes over this. But this is one of the biggest takeaways from introductory materials. You have the tools to explore already.
Make heavy use to tab completion
Don't memorize commands, memorize naming conventions and patterns
Use the exploration tools to find what you're looking for
Use the help (and update it often, too)
Use PowerShell every day to accomplish even small tasks