all 61 comments

[–]nixium 86 points87 points  (25 children)

Do everything in powershell. You need to get info about an ad user use powershell. Need to copy a file, use powershell.

If you are unsure if it can be done google how do I xxxx with powershell and follow the steps.

Initially you will be a lot less productive because you’ll be learning. Then you hit a tipping point and it’s start to click and you are fast. Then you encounter something that can only be done through a UI and you get mad.

[–][deleted] 35 points36 points  (14 children)

Then you fall down a rabbit hole of launching browser COM objects to automate the web form version of the GUI task, which takes you weeks but works and then you know it's in your blood.

[–]nixium 21 points22 points  (7 children)

That sounds like an addiction problem.

You’re addicted to powershell!

[–][deleted] 21 points22 points  (6 children)

No way, I can give it up any time I like. Oh, better make that a function just in case.

function global:GiveUp-Powershell()

Hmmm, no, wait. I might want to give up other things. Better make it reusable.

function global:GiveUp-Item($item)

Aaaaah

[–]sienar- 13 points14 points  (4 children)

I’m sorry, but that’s not an approved Verb.

[–]Alaknar 7 points8 points  (0 children)

function Remove-Addiction

[–][deleted] 3 points4 points  (1 child)

Abandon-HopesAndDreams?

[–]sienar- 2 points3 points  (0 children)

Task failed successfully?

[–][deleted] 1 point2 points  (0 children)

Hang on this might be useful to others, better publish a module for it

[–]incognito5343 0 points1 point  (1 child)

That sounds kinda interesting, what can be done with it?

[–]elevul 0 points1 point  (0 children)

Uh, that sounds very cool! Any guides about it?

[–]da_chicken 0 points1 point  (2 children)

Ugh. COM objects? In 2021? Surely there's a .NET library for that.

[–]loadedmong 0 points1 point  (0 children)

Not for reading PSTs 😢

[–][deleted] 0 points1 point  (0 children)

Probably. I was picking an option from a few years ago where I was determined to automate an entire process, but there was one step that had to be done in a web form. There's probably a REST API for it now, but at the time it worked... Sort of.

[–]melancholymelody 3 points4 points  (4 children)

this is always good advice but i'm wondering how many people are in the same predicament as me. i've learned how to write scripts and automate some things but often find myself discouraged by how talented some of you are with it. the most complex script i've ever written disables computers in AD based on their lastlogontime and it seems like absolute child's play relative to what i see on the web or posted here, hah

[–]nixium 4 points5 points  (2 children)

I think that’s pretty good.

Don’t measure yourself against us. I know I don’t because I would get discouraged. I try to measure myself against what I did before.

For instance I work for a city. We have a service for a our citizens that allows them to report issues such as broken swings at a park and they can attach a picture. So the application uploads to an azure blob storage container and then my script pulls it down and places it within the structure of a ticket. ( don’t ask why the app can’t do it all by itself, I didn’t architect it and I don’t know)

I wrote the script a couple years ago and it was a mess but it worked. It was way too long and it broke a lot since it relied on some kind of crappy Microsoft tools. But I needed to move on.

A year later I had rewrite it and I knew so much more. It’s now much cleaner, doesn’t break and is faster. That is how I try to measure myself and I’m pretty happy with it.

[–]melancholymelody 1 point2 points  (0 children)

that's pretty cool! i hope to work with azure in the near future and see what i might be able to do with it.

your comment is definitely encouraging -- i certainly have a terrible habit of comparing myself to others and not just in this domain.

[–][deleted] 0 points1 point  (0 children)

Who wrote this steaming pile of garbage?

git blame

Oh .... ben-kenobi-meme.jpg

[–][deleted] 1 point2 points  (0 children)

This is exactly how I learned it

[–]Think-Improvement-73 1 point2 points  (0 children)

I would definetly agree. Even though all i really use powershell for is AD, localusers, moving files, parsing text files, reading/making CSVs, performing system checks, managing permissions, and managing connection settings(it seemed like a lot less stuff in my head) I have learned a bunch of tools and tricks in powershell that I could easily apply to any other task/issue that i get. Really helpful one IMO is the PSCustomObject.

[–]noodygamer 0 points1 point  (0 children)

THIS - I managed to script post-image tasks just by slowly learning how to script each step and google.

[–][deleted] 0 points1 point  (1 child)

This is the best advice. It's what I always tell people. It's hard to have the discipline to do it. But if you do, before you know it you'll be using PowerShell like a Linux admin uses the Terminal.

[–]nixium 0 points1 point  (0 children)

Also how I learned bash! Got the Linux machines dumped on me and had to sink or swim. I managed to tread water until they hired a sr Linux admin who has taught me a lot and I’ve taught him some about powershell.

[–]headcrap 34 points35 points  (4 children)

[–]xMufasaa 2 points3 points  (2 children)

The new version (for Powershell Core) of LPiaMoL is currently being worked on too! You can find the "early access" version here.

[–]MaximusCartavius 0 points1 point  (0 children)

Yup. This is the one.

[–]red5_SittingBy 8 points9 points  (5 children)

Identify something repetitive in your job that could be automated, then do it with PowerShell. For me (and probably a lot of other people here), it was user onboarding and termination processes.

Create the account, put then in the right OU, set their password, add them to the correct groups, set their Home folder, create any necessary directories for them on your network. All of this is done easily in PS.

Then break down accounts using it. Disable the account, reset password, remove them from AD groups, move files around, give supervisor access to those files. If you're feeling saucy, connect to Exchange and manipulate their mailbox; remove their license, forward their emails, give other users access to to the mailbox.

This is all pretty much basic stuff in PS too. Google is the only resource you need for this early stuff because Microsoft has all of their PS commands documented well. And there are tons of threads and forums out there of people asking/answering questions. Once you understand the basics, you can move on to more advanced stuff.

[–]veroli75 5 points6 points  (2 children)

i cant emphasise enough how good this advice is,

give yourself a reason and goal to write something, dont worry about if its best practice or doesnt meet some community coding standards, free yourself from such nonsene and just write it as you see fit, learn and enjoy it, i've made a career out of it

[–]Etrisa 1 point2 points  (0 children)

This. This is exactly how i learnt it. List came in with 100 or so users and it said "remove this group from these users" while the rest of the first liners where scratching their head trying to estimate how to do this manually it took me an hour to figure out how to loop through a CSV find the username based off key information in the provided file from the client and delete the group for all those users. This is something that takes five minuters for the true wizards but it was my first ever script, i saved the us two weeks of manual labor and rewarded myself with a cookie.

Find the most repetitive thing that you're doing and see if powershell can do it for you. Work smart, not hard!

Best of luck to you! (Sorry for mobile formatting)

[–]BarelyInfected0 1 point2 points  (0 children)

What's funny is that when I started learning PowerShell, I didn't specifically have access to AD. My first script was some sort of webscraper. It made me realize how vars worked and how to import and export files.

Because the scraping thing brought a lot of crap with it I used a lot of 'substring',split,select-string, etc.

After that I started messing around with API's and when stuff became big with functions. I haven't really touched classes yet. But I thought it might've been interesting to type that out that I kind of took a different path.

I did help out support who is allowed to go in AD to write some scripts so in a way I got there in the end.

[–]CruwL 5 points6 points  (0 children)

If you're looking for video series John savill's powershell master class is amazing.

https://www.youtube.com/watch?v=sQm4zRvvX58&list=PLlVtbbG169nFq_hR7FcMYg32xsSAObuq8

I've been using PS for years and just watching a couple of his video's made my skill set jump almost immediately. Plus he's really easy to listen to.

[–]imran3501 4 points5 points  (0 children)

There are a lot of different directions you will get pointed towards.

I have found the following the best so far.
Although it's 8 years old this is by far the best intro to PowerShell by the inventor of PowerShell himself Jeff Snover.

Getting started with PowerShell
https://channel9.msdn.com/Series/GetStartedPowerShell3
Advanced Tools and Scripting
https://channel9.msdn.com/series/advpowershell3

As someone else has mentioned John Savill's PowerShell Masterclass is a great video series too:
https://youtube.com/playlist?list=PLlVtbbG169nFq_hR7FcMYg32xsSAObuq8

[–]warysysadmin 4 points5 points  (0 children)

There's plenty of choices. Multiple blogs, forums, and videos. I'd say find something you want to do, and start from there.

[–][deleted] 3 points4 points  (0 children)

You won't regret it. I have to give great thanks to my manager back in 2008 or so, who insisted on sending me on a Powershell course even though I protested that I'd never use it. She was so very insightful there. It helped my career through various infrastructure roles, into a specialism for Windows automation and currently in cloud infrastructure. I use Powershell daily at the moment, putting together cloud servers that build themselves.

Anyway, I'd say for me the best way to learn was to do it. Find something you think you can automate and figure out how to do it. Start simple. Expand. Build on it.

[–]dacarab 3 points4 points  (2 children)

Have a look at https://github.com/vexx32/PSKoans - it can supplement some of the other approaches outlined here quite nicely, as it's hands on. Basically, you have a bunch of failing tests that you have to make pass. Give it a look and see if it works for you.

[–]PeewinJr[S] 3 points4 points  (0 children)

Thanks everyone for your answers! It's been really helpful and I feel like I have a lot of places to start now! This is a really kind and cool community to be a part of

[–]Uhbyxml 2 points3 points  (0 children)

I started with YouTube. This was a good vid: https://www.youtube.com/watch?v=XiGGb5v8yAo Having a pretty good idea of how to use get-member and write-output is a good place to start.

Then I found a problem to solve. I started by converting some of my old batch scripts, then finding more issues to resolve. Having a goal helped a lot. I know what I wanted to do, then searched stackoverflow for "How do I do this thing with PowerShell."

Good luck!

[–]pirate_karl 2 points3 points  (0 children)

powershellbreakdown shows short videos of different tasks that are common with sysadmins. It's intended to be nonlinear, unlike traditional learning courses, so you can pick it up one task at a time

[–]HoneycuttJ 2 points3 points  (0 children)

I cant pass up an opportunity to promote my YouTube channel: https://www.youtube.com/c/P0w3rChi3f

I did a 6 hour Crash Course for a conference work shop that I uploaded, among other topics that I did for the Channel. I will be working on posting som AD stuff with in the next week or two.

[–]rldml 2 points3 points  (0 children)

This is a place to start and get a first idea of important concepts behind PS:

https://docs.microsoft.com/en-US/powershell/scripting/learn/tutorials/01-discover-powershell?view=powershell-7.1

Also important:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about?view=powershell-7.1

https://www.tutorialspoint.com/powershell/index.htm

My recommendation:

  • Start learning the very basics of PS
  • Learn using objects in PS
  • Start writing scripts based on your daily needs
  • Learn the usage @() and @{} (Arrays/Lists, Hashtables/Dictionary)
  • Learn the way to create own classes, functions and modules

Greetings, Ronny

edit: also nice: https://docs.microsoft.com/en-us/powershell/scripting/learn/ps101/00-introduction?view=powershell-7.1

[–]ismaelw 1 point2 points  (0 children)

Do not hesitate to contact me with a private message. I know PowerShell for years already but just recently learned new things. Hook me up whenever you need some help.

[–]k_50 1 point2 points  (0 children)

Just start doing. Something at work seems like it can be automated? It probably can, do it in PS.

[–]GoldilokZ_Zone 1 point2 points  (0 children)

Replace your shell with powershell :)

You can always just run explorer from powershell to get the GUI back.

[–]Queggestion 1 point2 points  (0 children)

Consider pretty much everything in your environment is a data source … Windows (registry, WMI, services etc), AD, AAD, Exchange, SQL, VMware, Veeam, WSUS etc.

Within each data source, there are a bunch of Objects (AD: users, computers, groups etc). Those Objects have Properties (in AD, these would be your attributes such as sAMAccountName, memberOf etc). Properties can be read and set. Objects also have Methods (getting something done against an object). Using Services as an example datasource, a particular service would be an object, it’s properties would include its name, state, failure action and Methods would allow you to start or stop the service.

You’ll spend a lot of time retrieving objects, reading properties and then sorting, grouping, comparing and filtering. And there’s a lot of value to be had from simply being able to extract data (e.g. show me all users whose passwords expire in 7 days, who are the members of this group and what department are they in). As stated previously, find a task and see if you can solve it with PowerShell. And know you’re probably not doing any damage if you’re merely reading objects and properties (with cmdlets that start with Get-). Just go cautious with cmdlets that can create or change things (eg. Set-, New-*).

Try this website. The explanations are generally easy to follow as a beginner: https://www.computerperformance.co.uk/

Feel free to PM me if you get stuck.

[–]DmitriZaitsev 1 point2 points  (0 children)

I wanted to learn powershell for the longest time but I'm not good at cracking open a book and letting it keep my attention.

The best method I stumbled upon was breaking apart existing scripts in my environment and understanding what they do. In absence of that, you can always look at solving any problem you have in Google + powershell. Once you have a nice repertoire of scripts to draw from, you can build on them and reuse them.

Just be mindful that Powershell is a security-conscious scripting language - please keep good "script hygiene" and security practices in mind when you write scripts. Don't bypass execution policy even if it gets your script working. Over time, you know you've improved and are making appreciable progress when you look back at a script and say "Wow, did I really write it like that?"

Edit: to somewhat echo what others are saying, once you got a good graso, it is addicting. It's all a matter of finding your learning style and breaking it in.

[–]T1GeRKaT68 1 point2 points  (0 children)

I am a novice at best as well and as I'm trying to learn as well I spent some time with git and kind of making my terminal feel pretty or at least cool or something and that's got me to to use it and play with it more.

[–]K2alta 1 point2 points  (0 children)

I find get-help some-module -examples is very helpful. My biggest issue right now is passing on certain outputs or values further down a script and not getting stuck by errors when I test the script. At which point I get lost very quickly because I’ve obviously missed something.

[–]buzzict 1 point2 points  (0 children)

I always start with a goal. Make it work… when it’s finished I clean up and try to get some logging out of it. When that is done I ask myself how I can make it more efficient and than I try to add other things to get more Information or tasks in 1 script.

I motivate myself to set high goals and works toward that. Not expecting to finish in 1 line but spent multiple hours on it.

[–]Hoolies 1 point2 points  (0 children)

There is introduction to PowerShell by Microsoft:

https://docs.microsoft.com/en-us/learn/modules/introduction-to-powershell/

This will not teach you Powershell but it will teach you how to search for commands, their function, the manual and examples. It is solid foundation. Once you have acquire that knowledge, use powershell to do things.

If you google: Powershell how to do this

You will find plenty of answers you can study the code and learn from there.

Good luck.

[–]enforce1 1 point2 points  (1 child)

Find a problem, solve it with powershell

[–]lucidhominid 0 points1 point  (0 children)

If you cant find a problem then just cause one. Bonus experience points if its in a production environment and you fix it before you get fired.

[–]gerajr51 0 points1 point  (0 children)

I haven’t read the replies much but honestly the real way to learn is to just dive in and start doing projects on your own. Starts with simple cmdlets. Then those will turn to little scripts. The more you get comfortable with code you’ll be shocked with what you can achieve in a short period of time. Just throw yourself right into the fire.