What are the hidden features of PowerShell?
Powershell – Hidden Features of PowerShell
powershell
Related Topic
- PowerShell – How to Check if Running with Administrator Privileges
- PowerShell Output Stops Until Enter Pressed – Causes and Fixes
- Windows – How to list hidden administrative shares using PowerShell
- Powershell – Is it possible to create a generalized configuration file for installing Windows features using PowerShell
- Powershell Unhide Folder
Best Answer
Force Powershell functions to really return an array, even an empty array.
Due to the way the @() syntax is implemented, functions may not always return an array as expected, e.g. the following code will return a $null and NOT an empty array. If you are testing code with
set-StrictMode -On
set, you'll get anPropertyNotFoundStrict
error instead when trying to reference the.count
property:Simply prepending a
,
to the@()
will bypass the "syntactic sugar" and you'll have an actual array returned, even if it's empty: