r/PowerShell • • Mar 04 '20

New PowerShell Version - v7.0.0

https://github.com/PowerShell/PowerShell/releases/tag/v7.0.0
160 Upvotes

70 comments sorted by

28

u/DigitalWhitewater Mar 04 '20

Please inform a ignorant fool... what is the hype and highlights in PS v7.0.0? I’m honestly curious.

39

u/firefox15 Mar 04 '20

Depends what you are comparing it to. Personally, I like the parallel processing ability that has been introduced with ForEach-Object.

19

u/azjunglist05 Mar 04 '20

I feel like that’s the only thing people ever mention about PS 7.0 - is that really the only major change that has been made?

I’ve been using Runspaces for awhile, so it being added to a foreach loop doesn’t really make me gung-ho about it. Genuinely curious though to see from user’s perspectives what has changed!

9

u/ka-splam Mar 04 '20

It's not a huge jump of 6 -> 7, it's more like 6.3 but they want the major version to signal improved compatibility and a long-term-support release. At lot of the work has been improving the auto-loading and module compatibility with PSv5 things so that v7 is not such a breaking change from 5.1.

There are a few differences - some gated features behind experimental enable/disable flags, some operators && and || and & used like Bash does, ?. and ?[] operators to make working with / testing for $null values need less code, ternary operator for shorter if/else test ? code : code; suggesting closely named commands in the case of a command not found, reworking Test-Connection to be more like v5.1 with more useful output, more kinds of numeric literals like 0b0011 for binary number literals, cross-platform get/set-clipboard, add colours and things to Select-String output, add back some cmdlets from PSv5.1 which didn't make it into the new ones such as Get-Hotfix, powershell can now be a login shell on Linux/macOS, better breakpoint display when remoting and debugging, -split can take negative count numbers to split from the right, Export-Csv doesn't need -NoTypeInformation anymore, DSC MOF compilation on non-Windows and use of DSC resources without an LCM, and a bunch of general cmdlet tweaks to parameters and options for convenience and bugfixing.

0

u/[deleted] Mar 04 '20

[deleted]

9

u/BlitzThunderWolf Mar 04 '20

What about active directory stuff on non-windows systems?

5

u/oW_Darkbase Mar 04 '20

I was wondering that aswell, I've heard multiple times that the new PS core versions do not support Active Directory cmdlets and other server administration cmdlets that come with server features / RSAT?

8

u/halbaradkenafin Mar 04 '20

That's worked since 1809 and PS 6.1 on windows.

3

u/Mayki8513 Mar 04 '20

"That's worked since 1809..."

Why was my first reaction "a bit of an exaggeration..." Lol >.<

7

u/Emiroda Mar 04 '20

I've heard multiple times that the new PS core versions do not support Active Directory cmdlets and other server administration cmdlets that come with server features / RSAT?

You've heard lies, or the word of fools. It's worked since 6.1.1 on Windows 10 1809.

https://www.reddit.com/r/PowerShell/comments/f6qef2/psa_activedirectory_module_works_natively_with/

3

u/mryananderson Mar 04 '20

Yes it has I’m wondering about Linux and Mac support. I know that it has to do with some of the .net libraries but wasn’t sure if they are working on it.

0

u/[deleted] Mar 04 '20

[deleted]

2

u/mryananderson Mar 04 '20

Thanks for that! This is literally the only reason right now I run a VM in parallels on my MAC, to run AD commands. I really hope it gets ported because it would make life a lot easier for simple lookups as well as scripts.

4

u/Emiroda Mar 04 '20

They've made them Core-compatible, so in theory they should work on non-Windows systems, but I don't think they've published the module to PowerShell Gallery.

2

u/rjmholt Mar 04 '20 edited Mar 04 '20

The AD module is still a Windows in-box module. It works with PowerShell 6.1 and up on newer Windows versions (because those versions have the version of the module that works with .NET Core), but Core-compatibility is not automatically cross-compatibility; the module probably has many assumptions about Windows in it still.

Cross-compatibility is a big work item. Taking PowerShell as an example, getting PowerShell to work and be useful on macOS and Linux took much more work than just porting it to .NET Core (although PowerShell started when .NET Core was much more constrained than it is now). Things like the filesystem, user management integration, cryptography libraries, all of that changes when you go between operating systems.

2

u/rjmholt Mar 04 '20

I should also say the AD module isn't part of PowerShell. I think a UserVoice issue like this one is the best place to let the relevant team know what you want.

1

u/halbaradkenafin Mar 04 '20

Still an issue I believe but you've got remoting as an option to be able to run that stuff so not a big problem really.

4

u/Emiroda Mar 04 '20

Not an issue. ActiveDirectory and most of the Windows modules are Core-compatible.

https://www.reddit.com/r/PowerShell/comments/f6qef2/psa_activedirectory_module_works_natively_with/

2

u/ihaxr Mar 04 '20

They can be core compatible and not work on Linux/Mac, though... which I'm fairly certain is still the case.

0

u/[deleted] Mar 04 '20

[deleted]

3

u/nick_nick_907 Mar 04 '20

This is the main point, IMO.

6 didn't really replace 5.1 because there were so many Windows Administration modules that weren't supported.

We had a cross-platform tool (Core/6) and a Windows admin tool (WindowsPS/5.1). Now we've got one tool for both.

5

u/azjunglist05 Mar 04 '20

Sweet! Thanks for the breakdown. The chaining and error message output is already sounding pretty worthwhile.

4

u/bozho Mar 04 '20

Is there a good source on PS 7 and Windows-only stuff and DSC?

We use DSC for Window servers' configuration management and a lot of resources depend on .NET Framework stuff. For example, SqlServer module is importable on PS 7. Importing the module in PS 5.1 adds several types used to manage SQL Server components, like [Microsoft.AnalysisServices.Role], but not on PS 7. I assume we'll have to wait and see if underlying assemblies get ported to .NET Core...

3

u/Beirbones Mar 04 '20

What's the chain operator do?

5

u/halbaradkenafin Mar 04 '20

Run the second command only if the first succeeds. I use it a lot in the command line for git commit && git push and similar

2

u/rjmholt Mar 04 '20

There are two of them in fact, the other is ||.

|| will run the second command if the first fails:

icacls .\ex.txt /setowner doesntexist || Write-Error "Did not set file owner"

1

u/segagamer Mar 04 '20

Is there a way to have it replace the Win+X, A/I shortcut?

1

u/[deleted] Mar 04 '20

May not fit your use case, but I recommend CMDER in Quake Mode.

0

u/[deleted] Mar 04 '20

[deleted]

2

u/segagamer Mar 05 '20

Yeah, until that becomes a possibility I just find this awkward to use.

0

u/[deleted] Mar 05 '20

[deleted]

2

u/segagamer Mar 05 '20

I can't use Windows Terminal though, because my local user account is not the same as my domain admin account. Plus occasionally I'd have to use the System Account.

Store apps are (stupidly) only ever possible to install on a per-user basis.

0

u/[deleted] Mar 05 '20

[deleted]

→ More replies (0)

1

u/nascentt Mar 04 '20

What's the situation in regards to compatibility with 5.1 commands?

I think 7 is core right so that means a lot of broken scripts?

0

u/[deleted] Mar 04 '20

[deleted]

2

u/nascentt Mar 04 '20

Testing thousands of scripts thoroughly to make sure they still work is not going to be possible anytime soon unfortunately. I'm going to guess ps 5.1 is going to be the next java 8

1

u/DigitalWhitewater Mar 04 '20

That’s definitely handy!

7

u/jsiii2010 Mar 04 '20

This blog sums up the new features. There'll probably be a new post soon. https://devblogs.microsoft.com/powershell/announcing-the-powershell-7-0-release-candidate/

1

u/DigitalWhitewater Mar 04 '20

Awesome, thank you.

2

u/Emiroda Mar 04 '20

I'm being cynical, but..

It's the first good PowerShell release since 5.1.

6

u/[deleted] Mar 04 '20

This is huge.

3

u/dany20mh Mar 04 '20

If this is the final release, what's the best way to install it?

I tried this command and it gives me 6.2.4:

iex "& { $(irm https://aka.ms/install-powershell.ps1) }"

If I add -Preview to it and use it like this, I get 7.0rc3

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -Preview"

5

u/halbaradkenafin Mar 04 '20

It's not quite there yet. The binaries haven't been published yet but should be in the next day or so.

2

u/rjmholt Mar 04 '20

This should work now that the change has gone in. Try the top command again now :)

3

u/Justify_87 Mar 04 '20

Does this finally replace Powershell 5.1? Or is it still it's own core release?

5

u/halbaradkenafin Mar 04 '20

It's a side by side install. Windows powershell is not going anywhere any time soon.

1

u/gex80 Mar 04 '20

That feels dirty.

1

u/halbaradkenafin Mar 05 '20

Why? We've had cmd shipping in Windows for years after it's been deprecated. It's there for backwards compatibility, the same is true for Windows PowerShell.

The support model for PowerShell 7 doesn't line up with Windows so there's some issues the team needs to work on to get it shipping in the box (if they ever can) and it'll still not replace Windows PowerShell since they have different features due to different versions of .Net. The compat is pretty close but not enough to remove 5.1 so we end up with side by side.

1

u/gex80 Mar 05 '20

Well I understand the technical reasons why its separate. But now we have cmd, powershell (5.1), and powershell7. Our automation tools like ansible can only call powershell. And I'm just so used to typing powershell, enter. From a user perspective it's more things to keep in mind. Like Ubuntu vs Centos. Sure they're both linux and sure they both work almost identical, but it still annoying to remember when to use yum vs apt and forgetting which you're on.

1

u/halbaradkenafin Mar 05 '20

Sure, but the automation tools will catch up and muscle memory will too. I'm only using it locally at the moment, I haven't rolled it out to the small number of servers I've got (and won't because I'd like to throw them away soon). For daily use I've got windows terminal pinned on my task bar and that defaults to 7 so I don't have to remember which I'm in (the background colour helps a bit) and have to make an effort to open 5.1 (pretty much just for when I need an admin prompt for chocolatey).

3

u/Emiroda Mar 04 '20

They've said somewhere (can't find it), that PowerShell 5.1 is going to have the same "support" as cmd has: Support forever, since it powers applications that won't get changed for 10-20 years.

3

u/pnlrogue1 Mar 04 '20

PowerShell 5.X and earlier use the full .Net framework. They are now called Windows PowerShell. Microsoft are not upgrading Windows PowerShell anymore.

PowerShell 7 uses .Net Core and is the channel that will continue to see active development. Wikipedia had a good section on this.

2

u/Justify_87 Mar 04 '20

I know but it was rumored that 5.x would eventually be replaced by a core release. There is some Microsoft blog mentioning it

2

u/Emiroda Mar 04 '20

https://twitter.com/Steve_MSFT/status/1213080494323224577

As Steve said, they'll make an announcement very soon.

1

u/pnlrogue1 Mar 04 '20

Eventually, but installing 7 will not remove 5 (unless they've changed something). You're probably going to be waiting until Server 2022 for that at a guess. PowerShell needs to be pretty much 100% backward compatible with existing modules in Windows before they could do that

2

u/gschizas Mar 04 '20

What I really want is a way to replace Out-GridView -passthrough

I've tried making a .NET pure text equivalent cmdlet, but I'm having trouble with the TUI handling (probably a library problem).

2

u/SeeminglyScience Mar 04 '20

You can also just keep using Out-GridView (it's back).

1

u/gschizas Mar 04 '20

Oh, cool. But I really wanted to make a text-only equivalent (but it's not a stopper now).

1

u/SeeminglyScience Mar 04 '20

You and me both my friend. You and me both.

2

u/rjmholt Mar 04 '20

The GraphicalTools module has a prototype of this. Works really nicely

1

u/gschizas Mar 04 '20

Oh my! I think that's what I was trying to build. And with that exact framework, too!

How come I didn't even know this was a thing?

2

u/fatalicus Mar 04 '20

Fantastic! Now update all the Microsoft 365 modules so I can use them in core with modern auth.

1

u/Tekwhat Mar 04 '20 edited Mar 04 '20

Just use conditional Access to not prompt for MFA inside your companies public IP range. Works great for Powershell.

2

u/rjmholt Mar 04 '20 edited Mar 04 '20

The release just went live then (the tagged commit in the OP had to be set up beforehand).

Some handy links for you:

A couple of bits might take a day or two extra to come out:

  • The MSIX (it will go to the release page above and you can install it with Add-AppxPackage -Path $pathToMsix)

  • The macOS Homebrew package is community maintained, so usually comes out 24-48 hours after the release is published

1

u/tstephansen Mar 04 '20

Does it actually work with VsDevShell now? I used ps core with the vs command line until the released the powershell module. It didn’t work with ps 6 though so I went back to regular powershell.

1

u/jonr7670 Mar 04 '20

Dumb question alert. I downloaded the zip. I can't see the installer. How do I install it?

2

u/Emiroda Mar 04 '20

The link up top is just source code. They haven't written the fancy announcement posts yet, so installers aren't downloadable yet.

If you want to learn something new and compile the source code yourself, here's how: https://github.com/PowerShell/PowerShell/blob/master/docs/building/windows-core.md

1

u/poshftw Mar 04 '20

https://github.com/PowerShell/PowerShell and scroll to 'Get PowerShell' section.

0

u/[deleted] Mar 04 '20

[deleted]

5

u/jborean93 Mar 04 '20

The AD modules have worked with PowerShell Core (on Windows) for a while now. You just need to make sure your Windows install is new enough to contain the compatible cmdlets. For me the AD cmdlets work on Server 2019 which I believe is on the same build as Windows 10 1809. Potentially older versions also work but I don't have any of those builds to test.

PS C:\Windows\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.2.4
PSEdition                      Core
GitCommitId                    6.2.4
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS C:\Windows\system32> Get-ADUser vagrant-domain

DistinguishedName : CN=vagrant-domain,CN=Users,DC=domain,DC=local
Enabled           : True
GivenName         :
Name              : vagrant-domain
ObjectClass       : user
ObjectGUID        : 928a0ddf-e92b-4c7f-8d59-3337956f5c94
SamAccountName    : vagrant-domain
SID               : S-1-5-21-2959096244-3298113601-420842770-1104
Surname           :
UserPrincipalName : [email protected]

1

u/Sebazzz91 Mar 07 '20

So it doesn't work on plain Windows Server 2016.

1

u/jborean93 Mar 07 '20

I’m pretty sure server 2016 is based on Windows 10 1607 which definitely doesn’t have the ad module version that supports PowerShell core. PowerShell 7 should still have a way to import modules that aren’t compatible through implicit remoting but you would have to test that.

3

u/halbaradkenafin Mar 04 '20

It works on 1809 onwards and with PS Core 6.1 or remoting to a box with them.

1

u/Emiroda Mar 04 '20

Are the ActiveDirectory and grouppolicy modules working when hosted on Windows?

Has worked since 6.1.1.

https://www.reddit.com/r/PowerShell/comments/f6qef2/psa_activedirectory_module_works_natively_with/