Powershell 7 features

Website Visitors:

Here are list of some of the powershell 7 features:

  • Pipeline parallelization with ForEach-Object -Parallel
  • New operators:
    • Ternary operator: a ? b : c
    • Pipeline chain operators: || and &&
    • Null conditional operators: ?? and ??=
  • A simplified and dynamic error view and Get-Error cmdlet for easier investigation of errors
  • A compatibility layer that enables users to import modules in an implicit Windows PowerShell session
  • Automatic new version notifications
  • The ability to invoke DSC resources directly from PowerShell 7 (experimental)


If left side operation/variable is not null, then it will process left side operation. If it is null, then it goes to right side.

$left = 10 $right = 20 $left ?? $right output is 10 as $left is not empty. $leftt = $null $leftt ?? $right will show 20 as $leftt contains null, it is empty.

(Get-ChildItem -Path ./FakePath ) ?? (get-date) This will output date as you entered fake path.

Note: you can also use ! in the left hand side to make true statement false, or false statement true.


assign value on the right side to the left hand side variable, it is not empty.

$test = $null $test ??= “Some Value” $test would result “Some Value” because $test is null, so it assigned “some value” to $test.

$one = 10 $one ??= “New value” Here, $one will stil be 10, because it is not null. so “new value” is not assigned to $one.

Get-Error: use get-error to see the last error and its details.Instead of writing the whole if else commands in functions, you can use ? and : to find if some condition is satisfied and write outputs accordingly.

Ternary Operator:

? :

(10-5) -gt 20 ? “True” : “False” output will be false. 10-5=5. 5 greater than 20 ? no. so false will be output. Instead of writing if else, in posh 7 you can use it.

open-editorfile filepath - opens file in vscode for editing. new-editorfile - opens a new untitled file for editing.

ErrorView types in Posh 7:

The valid values are as follows:

  • ConciseView: (Default) Provides a concise error message and a refactored view for advanced module builders. If the error is from command line it’s a single line error message. Otherwise, you receive a multiline error message that contains the error and a pointer to the error showing where it occurs in that line. If the terminal supports Virtual Terminal, then ANSI color codes are used to provide color accent. The Accent color can be changed at $Host.PrivateData.ErrorAccentColor. Use Get-Error cmdlet for a comprehensive detailed view of the fully qualified error, including inner exceptions. ConciseView was added in PowerShell 7.
  • NormalView: A detailed view designed for most users. Consists of a description of the error, and the name of the object involved in the error.
  • CategoryView: A succinct, structured view designed for production environments. The format is as follows:{Category}: ({TargetName}:{TargetType}):[{Activity}], {Reason}

$errorview is set to ConciseView by default in Posh 7.

Checkout Powershell Video Series here:

Want to learn more on Citrix Automations and solutions???

Subscribe to get our latest content by email.

If you like our content, please support us by sponsoring on GitHub below: