From the course: PowerShell 7 Essential Training

PowerShell 7 - PowerShell Tutorial

From the course: PowerShell 7 Essential Training

Start my 1-month free trial

PowerShell 7

- [Instructor] So what's new in PowerShell 7? Well, the first thing is that there are directory changes that have been made to where PowerShell 7 is actually installed. It gets installed into a new directory and will allow you to run PowerShell 7 alongside PowerShell 5.1. New to obviously PowerShell 7 is pipeline parallelization. So you can now execute or handle objects in parallel instead of the standard sequence method. If you're using, for example, the ForEach-Object, you can now pass a parameter called parallel. There are also new operators that are available. There are three: they're called ternary operator, so A, question mark, B, colon, C; there's pipeline chain operators. So the two pipe commands and the two and, and then of course there's null condition operators. Question mark, question mark, or question, question mark, equals. And we'll talk more about this as we go forward. Then of course, we have two new cmdlets. So ConciseView and Get-Error cmdlet. ConciseView is a user-selectable view which is enabled as the default view for PowerShell 7. Then of course, the Get-Error cmdlet would allow you to get detailed view of the error that was raised in the console. Microsoft also provide automatic new version notifications. So starting with PowerShell 7, the system will check for updates once a day and will notify you about a new version if that's available. The information is shown only at the start of the PowerShell session. So, what are the PowerShell directory changes? Well now, it's installed into %programfiles%\PowerShell\7. The %programfiles% path is also added to the environment variable called "Path Automatically." Within PowerShell 6, there were directory changes from installing PowerShell 7. So PowerShell 6 would have gone into a certain location, but on Windows, it's been moved to %programfiles%\PowerShell\7. On Linux, it's moved to /opt/microsoft/powershell/7. And then on macOS, it's moved to the user directory. So local/microsoft/powershell/ and 7. So let's talk about pipeline parallelization. Well, the idea is here that, when we're utilizing the ForEach-Object command, that we can utilize this -Parallel parameter, which we can add to the existing ForEach cmdlet. Normally when you use the ForEach-Object cmdlet, each object is piped to the cmdlet is then processed sequentially. But with the new ForEach-Object with the parallel parameter set, you can run all the scripts in parallel for each of those piped input objects. From a new operator perspective, we already mentioned that there are ternary objects, pipeline operators and null conditional operators. These behave like a simplified, If L statement. They'll make it easier to write code instead of using if and (indistinct) loops all of the time. The ConciseView cmdlet, obviously as mentioned before, is a user-selectable view which is enabled for the default view. If the error is not from the script, you'll receive a single error. However, if it's from the script, and there is a passing error, you'll receive a multiline error message and then a pointer showing in which line the error occurred. So very similar to receiving a stack trace, if you've been used to writing code, for example, in .NET or even in regular PowerShell. The Get-Error cmdlet helps get the detailed view of the error. So this will display full details, inner exceptions and the last error that actually occurred. Now the automatic version updates check every single day. The information is shown at the start of the session. There are three flags available for the PowerShell update. So default is GA, preview and RC releases. If you're utilizing Off, it turns off the update notification feature. And then we have what's called LTS. So, this only notifies of long-term servicing GA releases, and this is set within an environment variable called POWERSHELL_UPDATECHECK.

Contents