r/PowerShell • u/Reddit_Sux_Hardcore • Sep 17 '21
Question Why do Powershell cmdlets change so much?
I've been trying to follow along a month of lunches, and quite a few commands can't be used anymore. How is one supposed to follow along?
Why do they keep changing them?
Won't this mess up people's scripts that they've written before? When are they going to stop changing them.. and why do they change them? Makes me a bit worried.
I want to master Powershell, but if the cmdlets keep changing, wtf?
Thanks.
3
u/silenceredirectshere Sep 17 '21
What edition of the book are you using? Things are evolving as is the case with any programming language.
What's your future use case for Powershell? There might be more current resources for learning, but it depends on what you need to learn.
2
u/Reddit_Sux_Hardcore Sep 17 '21
I'm on the 3rd edition, but things have changed even since then.
I just want to master Powershell for work purposes. I'll be stealing/building on other people's scripts for the most part.
3
u/silenceredirectshere Sep 17 '21
I think the third edition is now five years old, you're better off searching for specific concepts you need and going through the Microsoft docs when necessary, after you've gotten the basic syntax down.
1
3
u/Ironic_Jedi Sep 17 '21
It's important to remember that windows 10 computers will generally have 5.1 installed. So unless you are writing scripts mainly for yourself that will run on your own machine/server then you should generally stick with 5.1 commands.
Don't forget there are plenty of modules you can install? I use the Az module a lot as I work with azureAD and intune joined devices.
I have one machine running the latest powershell version but my workhorse pc does not as I more often than not target 'standard ' windows devices.
Just something to keep in mind.
1
3
u/Thotaz Sep 17 '21
Microsoft focuses a lot on avoiding breaking changes, to the point where it hurts PowerShell a little bit. Look at a cmdlet like Join-Path, it started out with a "Path" and "ChildPath" parameter and then they later added an "AdditionalChildPath" parameter instead of updating the "ChildPath" parameter to be a string array.
Anyway, I'm sure there are some edge cases that have been broken but for the most part scripts written in older versions will work just fine in newer versions. You will have to name explicit examples if you want to know more.
2
u/Reddit_Sux_Hardcore Sep 17 '21
Ok, I'll keep learning and see how it goes.
My buddy who writes in PHP said it's been around for awhile, so things don't change that much, as opposed to Powershell which is still in its infancy, he said.
5
u/nealfive Sep 17 '21
PHP was released around 1994 and PowerShell around 2006, so it has a few years on powershell.
Windows PowerShell 5.1 and PowerShell (6/7) are fundamentally different and Windows PowerShell (5.1) is .NET based and PowerShell (6/7) is .NET Core based which also works on Linux and such.
Windows PowerShell (5.1) is considered 'complete' and all new development goes into PowerShell (6/7)
All the commands in Don's book should work just fine Windows PowerShell (5.1) as that's what it was written for, yes the latest edition of the book has more stuff to accommodate more to 7 but still, most stuff is for Windows PowerShell,rather than powershell.
It's a bit like Python 2 and 3. While mostly the same, they are still pretty different.
1
0
Sep 17 '21
[deleted]
2
u/Reddit_Sux_Hardcore Sep 17 '21
Yea I'm always updated the latest Powershell.
0
Sep 17 '21
[deleted]
-4
u/Reddit_Sux_Hardcore Sep 17 '21
Yea I'm in the latest PS, because I like the latest thing. I can't help it sir.
5
u/chuck_cranston Sep 17 '21
If you're "getting gud" at PowerShell and expecting to use it in an enterprise environment I would suggest getting familiar with the version that is most likely to be installed on all your machines. By default that's going to be 5.1 for windows 10 PC's.
There's a ton of great additions in PS 7 but I'm unable to get it deployed throughout the organization I work at so I write the majority of my stuff in 5.1.
Knowing the Cmdlets isn't as important as know how PowerShell works. Your learning experience is going to be less painful if you use the same version as the book.
1
u/Reddit_Sux_Hardcore Sep 17 '21
Oh, I thought that if you install the latest on your client and server it would be fine, no matter what you run.
So each client needs to have the latest version installed for it to work all over the workplace?
2
u/jimb2 Sep 18 '21
If you are in a corporate environment the default installation of Power shell will be 5.1 on both Windows desktops and servers.
The business is unlikely to upgrade PowerShell on everything without a good reason. It's too much work, testing and remediation. PowerShell is not updated via standard Microsoft updates. Even if it was part of Microsoft updates (and it probably should be) that would update to the latest 5.1.x. A version change to PS7 would break stuff everywhere.
1
u/Reddit_Sux_Hardcore Sep 18 '21
If you are in a corporate environment the default installation of Power shell will be 5.1 on both Windows desktops and servers.
This is true.
The business is unlikely to upgrade PowerShell on everything without a good reason. It's too much work, testing and remediation.
I can install the latest powershell on all client computers at work if I wanted to.
But you're saying I shouldn't?
1
u/jimb2 Sep 18 '21
You can, but you should probably consider that you will be moving away from the common "industry" standard.
We have like 10k+ desktops and several hundred servers at work so consider changes carefully. PS7 has a few nice features but nothing to die for. If we use a third party script it is almost certain to be written to 5.1.
1
u/Reddit_Sux_Hardcore Sep 18 '21
PS7 has a few nice features but nothing to die for.
Yea, my problem is that I thought PS7 was just an update to PS5, and that MS just didn't update the one on their OS.
5
u/joel_m_miller Sep 17 '21
You are using the wrong product for the book. The book is called Learning WINDOWS Powershell. You install PowerShell which is a new product that did not exist at the time of writing that book. Windows PowerShell has a newest version of 5.1. PowerShell is a different product and is version 7.1.4. Windows PowerShell uses Powershell.exe. PowerShell uses pwsh.exe and is a cross-platform tool. The newest version of the book was released in Dec 2016. The book has an updated intro that calls this out as well. If there is something specific that does not work for you, why not call that out here and people can assist? Or you can comment and ask the author at manning.com. Be specific on your questions and people here can help you out.
1
6
u/[deleted] Sep 17 '21
Like what commands are you talking here? I've used the same ones for AD, Office 365 for a while without issue. Sure, there may be some that get updated/added parameters, or even new cmdlts that will add functionality. There's also some that will lose support over time in favor of something new to replace it.
The only time I can recall in the last five-ish years of having to update a script for something new is because a new command came out (Exchange Online PowerShell V2 for example) or the SharePoint-PnP module getting sunset in favor of PnP.PowerShell. While the commands are the same, it just may require a different module.
If you follow the community or this sub, you'll see if certain commands/parameters are going to change, making it easy to test/plan for when that change happens. With PoSH, there's many ways to get from start to end, and things will always change over time no matter what. That shouldn't sway you away from learning it though.