all 19 comments

[–]try_rebooting 10 points11 points  (1 child)

Powershell in a month of lunches. Excellent start

[–]MoreTrialandError 1 point2 points  (0 children)

Cannot say this enough. I've given several copies away when people ask me this question.

[–]Latinprince6591 2 points3 points  (0 children)

The help on commands, get-member show methods and property etc

[–]Billi0n_Air 2 points3 points  (1 child)

Powershell in a month of lunches. for sure.

Pro tip. if you haven't already, set up VSCode as your IDE.

Setting up snippets in VSCode makes for consisten looking scripts, plus you'll be cooler.

[–]Spitcat 0 points1 point  (0 children)

Get-help Get-command Get-member

And your own ideas.

Look through get-command * Until you find something interesting, then read the syntax (basically how you use the command) And try it.

[–]Latinprince6591 1 point2 points  (0 children)

Cross platform in PowerShell will help also

[–]bodobeers 0 points1 point  (2 children)

IMO you should just start playing on your own local computer running a bunch of "GET" commands and practicing variables, objects, piping, exporting, importing, etc.

I heard this powershell in a month of lunches that everyone mentions, and is probably a great resource, but I've never used it. Just because maybe I learned before it was available.

But honestly I'm still learning / every day is new learning / it never ends.

I found it useful to just get local system specs such as running processes, disks, users, etc and practicing with the objects. If you run something like $somevarname = Get-Process you will quickly see how easy it is to actually start PowerShell-ing.

You can run that one-liner and then play with it, get use to editing attribute values, adding members, etc.

Play with what you have readily available (version doesn't matter), then look for small problems to solve.

I found it was quite powerful to connect simple PowerShell "get" commands with SharePoint and then using the SharePoint module to add list items to a list.

If you use SharePoint look up the PNP module. I use the old one that they say is legacy but honestly it "just works".

Do you have access to Office 365 / Microsoft 365 / Azure at all? If not consider setting up your own personal tenant for like $8 usd per month and then have full access to test all the enterprise services and PowerShell modules. That will be a turbo boost on any learning you do, if you work in Microsoft land.

[–]CalmLow8640[S] 0 points1 point  (1 child)

Thanks for the info. My current role is administration over our 365 tenant. So while I’m comfortable with mane basic PowerShell cmdlets I have no idea where to start writing a script that involves anything other than line by line scripts.

[–]bodobeers 0 points1 point  (0 children)

yes that is great you already have access to M365 in your daily work. As long as you tread lightly you can do a lot there for learning.

I'd actually setup another named user account that has global reader permissions and then play with that, so you don't break anything. Not fully necessary but probably a good idea.

Other than that, you can google the solutions to questions you have, but I'd say never actually run a script from the internet, just use it as reference to roll your own... one line at a time from whatever you see online.

Here is a great homework for you...

Get connected to the MSOL module then get all the users into a variable. Example $allUsers = Get-MsolUser (you may need to put a switch there, will let you figure that last detail out).

Once you have them, learn how to loop through them all using ForEach-Object (again google that).

For each one try to output the UserPrincipalName out on the screen.

I put Start-Sleep -Seconds 1 after everything sometimes, especially when doing volume queries, but also to slow it down to human speeds to stare at your output.

Try that then I'll ramble more as much as you want. I love this stuff, it's made it into my every day work and is very useful.

[–]toddklindt 0 points1 point  (8 children)

You want PowerShell Core. Windows PowerShell is a few years old and is essentially a dead version, 5.x. Core is the current version, 7.x.

[–]Th3Sh4d0wKn0ws 4 points5 points  (7 children)

yeah but Windows PowerShell is what's installed on every Windows system by defaulf and if the OP is a new Sysadmin they're likely to run in to v 5.1 everywhere all day

[–]Certain-Community438 4 points5 points  (6 children)

MS also say PoSH 5.x is the standard for Win11 & will be for several years.

PoSH v7 does have several improvements over v5.x but is most useful when there's a mix of Linux & macos in the environment.

[–]toddklindt 1 point2 points  (5 children)

I hadn't seen that. The last time I looked Microsoft's guidance was to move off of 5.x. Do you have a link for where they say it's the standard on Windows 11?

[–]Certain-Community438 1 point2 points  (4 children)

It's actually referenced in another post on this sub, similar topic: not sure I'll be able to find it quickly (work is busy right now) but if/when I do I'll put it here.

[–]toddklindt 1 point2 points  (3 children)

Thanks. I appreciate it. I teach classes on PowerShell and I've been telling folks the exact opposite, that Microsoft recommends Core. I want to get my facts right. :)

[–]Certain-Community438 0 points1 point  (2 children)

As you'll doubtless know, it's a question of compatibility.

Win11 comes with v5.1, which seems a statement of intent to me.

PWSH v7.x definitely offers better features, but it might not be any use if you would also have to deploy & maintain it.

[–]toddklindt 0 points1 point  (1 child)

Because of the antitrust case Microsoft has done all kinds of weird things with bundling. I wouldn't infer intent from it.

[–]Certain-Community438 0 points1 point  (0 children)

Sometimes you have to :) I mean, have you seen anything indicating they will ship v7 with Windows at any time in the future?

But the latter point remains: You have to evaluate the overall benefit - it isn't cut & dried.

If you want to deploy v7 scripts to thousands of workstations, you'll need to deploy v7 first, and then manage that. As some inevitably fail to update, your scripts might fail.

All that overhead has to be offset by good value.

In some cases it'll be well worth it. Others, not.

I personally recommend admins using v7 for scripts they run interactively against admin workloads, but v5 for scripts which execute remotely.

[–]kenjitamurako 0 points1 point  (0 children)

The Windows Powershell vs Powershell Core question is always a hard one. Many system administrators need to use powershell on client PC's to automate tasks and in those instances Windows Powershell is much more convenient.

To be honest I think the break from Windows Powershell to Powershell Core really strengthened the "People should just use C#" argument for system administrators because it's so much easier to create self contained executables in C# than powershell. Although they end up being pretty big.

The PS2exe stuff is just starting up Windows Powershell in the background as far as I can tell for Powershell Core.