r/PowerShell • • Oct 23 '19

New PowerShell Version - v7.0.0-preview.5 Release of PowerShell Core

https://github.com/PowerShell/PowerShell/releases/tag/v7.0.0-preview.5
114 Upvotes

50 comments sorted by

21

u/mxjq2 Oct 23 '19

Yes null coalescing!! No more inline if else statements.

0

u/[deleted] Oct 23 '19

[deleted]

4

u/clockKing_out Oct 24 '19

Details on the tech debt?

0

u/[deleted] Oct 24 '19

[deleted]

5

u/SteveL_Msft Software Engineering Manager, PowerShell Oct 24 '19

It's a big breaking change to not allow `?` as a valid character in a variable name. Other languages, like Rust, actually promote its usage so it would not be rare to see it used in PowerShell. Null conditional member access is still coming, but will require braces.

3

u/ThatNateGuy Oct 24 '19

Will this be in the GA release of PS7 or will that be in a later release?

2

u/SteveL_Msft Software Engineering Manager, PowerShell Oct 24 '19

Targeting to be in Preview6 (our last preview). If it doesn't make it, it won't be in PS7 but a release after that.

3

u/jantari Oct 24 '19

Oh my God really? It's a new major version for FUCK sake, make some breaking changes instead of requiring ridiculous braces, what hellish syntax....

0

u/[deleted] Oct 24 '19

[deleted]

1

u/jantari Oct 24 '19

imaging having the chance to start over and do it right and willingly deciding to do it wrong AGAIN ...

1

u/Ominusx Oct 24 '19

It will require braces?????

2

u/rjmholt Oct 24 '19 edited Oct 24 '19

The problem is script module compatibility. This comment in the C# repo sums it up best. It needs to be possible to write modules that work with PowerShell 5.1 and PowerShell 7.

Some APIs have changed behaviour, and that's tolerable since you can script around them:

if ($PSVersionTable.PSVersion.Major -ge 7)
{
    $x = [NewApi]::Call()
}
else
{
    $x = [OldApi]::Call()
}

But a change in how syntax behaves is much harder to deal with:

$x??=1

Does it assign 1 to $x??, or does it assign 1 to $x when $x is $null?

PSScriptAnalyzer wouldn't be able to pick that up easily, since it relies on how PowerShell "sees" the script (the AST), which is what's been changed.

And for the same reason, you can't just embed it in an if statement. Because the syntax operates at a layer before the if is executed.

Imagine:

if ($PSVersionTable.PSVersion.Major -ge 7)
{
    $x ??= 1
}

Even though you put the new syntax in an if, it won't work with PS 5.1.

So syntax is somewhere where a breaking change has deeper consequences.

7

u/signofzeta Oct 24 '19

Null coalescing, ForEach-Object -Parallel, and now I have my && and || operators? Push this to every Windows 10 machine worldwide already! PowerShell 6 is my daily driver and it’s already looking dated.

1

u/dextersgenius Oct 24 '19

And Server 2016 as well please!

0

u/[deleted] Oct 24 '19

[deleted]

2

u/XPlantefeve Oct 24 '19

I heard there were some nifty editors for CP/M, too, these days... :p

0

u/jantari Oct 24 '19

If only I could remotely brick your Win 7 install

3

u/rjjm88 Oct 24 '19

Here I am, stuck using Powershell v2 because my clients are afraid of change. Sigh, I shall dream of you, Powershell v7.

3

u/Swarfega Oct 24 '19

v6 onwards doesn't replace/upgrade Windows PowerShell so why can't you install 6 or 7?

2

u/SteveL_Msft Software Engineering Manager, PowerShell Oct 24 '19

Exactly! PS6/7 deliberately works side-by-side with Windows PowerShell. PSv2 is the worst because it doesn't have all the latest security enhancements to PS including Antimalware scanning and detailed logging among other security improvements.

5

u/Atomic0691 Oct 23 '19

I think the last piece preventing me from migrating is lack of Active Directory connectivity. I’ve seen they want to provide an avenue to make this work in 7; does anyone know if this is still planned for 7.0?

3

u/signofzeta Oct 24 '19

Are you talking about the [ADSI] cast operator, or the ActiveDirectory module from Windows Server? I’m really missing the latter.

4

u/Atomic0691 Oct 24 '19

ActiveDirectory Module

2

u/signofzeta Oct 24 '19

I hear you. I’m waiting for AzureAd, MsOnlineServices, and maybe MicrosoftTeams to get ported to modern PowerShell.

10

u/SteveL_Msft Software Engineering Manager, PowerShell Oct 24 '19

We have another feature coming in Preview 6 that will allow importing Windows PowerShell only modules into PowerShell 7. https://github.com/PowerShell/PowerShell-RFC/pull/226/files

1

u/signofzeta Oct 24 '19

That’s wonderful. I’m just surprised Microsoft hasn’t updated more of their other modules, like AzureAD and MicrosoftTeams, for .NET Core compatibility.

3

u/SteveL_Msft Software Engineering Manager, PowerShell Oct 24 '19

AzureAD is coming. It already works in Azure CloudShell which runs on Linux using PSCore6.2. Not sure about Teams. We'll be engaging more teams within Msft about PS7 compatibility as we get closer to GA.

1

u/nerddtvg Oct 24 '19

Yeah but Cloud Shell uses a preview version called AzureAD.Standard.Preview based solely on .NET Core. It works... Up until you use SearchString on a Get-AzureADUser request.

1

u/nerddtvg Oct 24 '19

So have you tried it? The module compatibility fixed in PS7 lets you run this module just fine. Plus the module is entirely up to the AD product team, not PowerShell team.

2

u/Inquisitor_ForHire Oct 24 '19

I think everyone understands that the module compatibility is up to the product team, but you'd think there would be some executive hammering the "get compatible" message up and down the product teams. The flagship "products" from MS should all have compatible modules. I can even understand not doing them for PS6 as we can consider that a transitional shift, but for PS7 it should absolutely be required.

1

u/nerddtvg Oct 24 '19

Since the AD module, among others, relied so heavily on .NET Framework calls that are not compatible or have alternatives in .NET Core, it was a lot more than just saying "get compatible." The delay was waiting .NET Core 3 which brought a lot of .NET Framework functionality into .NET Core.

With PowerShell 7 using .NET Core 3.0, we've seen a much greater increase in compatibility. And now that only few outliers remain, it makes it a much more manageable task to fix those modules.

https://devblogs.microsoft.com/powershell/the-next-release-of-powershell-powershell-7/

PowerShell Core 6.1 brought compatibility with many built-in Windows PowerShell modules, and our estimation is that PowerShell 7 can attain compatibility with 90+% of the inbox Windows PowerShell modules by leveraging changes in .NET Core 3.0 that bring back many APIs required by modules built on .NET Framework so that they work with .NET Core runtime. For example, we expect Out-GridView
to come back (for Windows only, though)!

So have you tried many of the native Windows modules in PS7? How many have you found that don't work at all or at least partially?

1

u/nvpqoieuwr Oct 24 '19

the module is entirely up to the AD product team, not PowerShell team.

This doesn't matter even a little bit. It's Microsoft's problem, and they need to make sure it's fixed.

1

u/nerddtvg Oct 24 '19

So have you tried it? Because it works in PS7 just fine.

1

u/nvpqoieuwr Oct 24 '19

I have no use case for it, but I've seen that sentiment since PSCore was announced.

1

u/nerddtvg Oct 24 '19

So PowerShell Core 6 was releasted in January 2018. We're nearly two years past that now.

1

u/nvpqoieuwr Oct 24 '19

Yeah, and the excuse that "Other team is supposed to do this" still doesn't hold water. Ever. Never did, never will.

You don't see Ford put a car out and say "Well, yeah, we changed everything about it, and it uses square tires now, but the tire division is responsible for it."

1

u/SteveL_Msft Software Engineering Manager, PowerShell Oct 24 '19

I think the point /u/nerddtvg was making is that the AD Module was fixed for compat with PSCore6.1 a long time back...

→ More replies (0)

2

u/KevMar Community Blogger Oct 24 '19

It's mostly worked for a while. I think one of the common bugs is resolved in 7.0. what issue are you running into?

2

u/theycallmebigbird12 Oct 23 '19

I wonder how long it will take PS 7, when released, to become available on the Linux repositories.

4

u/SteveL_Msft Software Engineering Manager, PowerShell Oct 24 '19

It usually takes less than a day. We publish it to the Msft Linux repo immediately but takes maybe an hour or so for it to show up.

1

u/theycallmebigbird12 Oct 24 '19

Glad to hear. Thanks!

0

u/[deleted] Oct 23 '19

[deleted]

12

u/rjmholt Oct 23 '19

Set the environment variable POWERSHELL_UPDATECHECK_OPTOUT to 1 or true or yes before starting pwsh, and it won't do the check

5

u/sir_sandwiches_a_lot Oct 24 '19

That enhanced/clearer error output would be fantastic. The current format does trip up beginners a lot.

3

u/Swarfega Oct 24 '19

Off-topic but does anyone know how I can replicate Steve's examples where it shows the execution time and current path?

[28.72ms] /Users/steve/repos/PowerShell

5

u/[deleted] Oct 23 '19

[removed] — view removed comment

4

u/[deleted] Oct 23 '19

[removed] — view removed comment

0

u/[deleted] Oct 23 '19

[deleted]

0

u/taw20191022744 Oct 25 '19

Ok, being new to PowerShell, what's wrong with it? Why is one way better?

0

u/[deleted] Oct 24 '19

[deleted]

2

u/Lee_Dailey [grin] Oct 24 '19

howdy taw20191022744,

they are talking about readability. [grin]

breaking the -replace 'this', 'that' on the comma works but is seriously more difficult to scan when reading code.

take care,
lee

2

u/taw20191022744 Oct 25 '19

Thx for the explanation!

1

u/Lee_Dailey [grin] Oct 25 '19

howdy taw20191022744,

you are quite welcome! glad to help a little bit ... [grin]

take care,
lee

1

u/AutoModerator Oct 24 '19

Sorry, your submission has been automatically removed.

Accounts must be at least 1 day old, which prevents the sub from filling up with bot spam.

Try posting again tomorrow or message the mods to approve your post.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.