@@ -32,15 +32,15 @@ operators on any .NET type that implements them, such as: `Int`, `String`,
3232Bitwise operators (` -band ` , ` -bor ` , ` -bxor ` , ` -bnot ` , ` -shl ` , ` -shr ` )
3333manipulate the bit patterns in values.
3434
35- For more information, see [ about_Arithmetic_Operators] [ 05 ] .
35+ For more information, see [ about_Arithmetic_Operators] [ 06 ] .
3636
3737## Assignment operators
3838
3939Use assignment operators (` = ` , ` += ` , ` -= ` , ` *= ` , ` /= ` , ` %= ` ) to assign, change,
4040or append values to variables. You can combine arithmetic operators with
4141assignment to assign the result of the arithmetic operation to a variable.
4242
43- For more information, see [ about_Assignment_Operators] [ 06 ] .
43+ For more information, see [ about_Assignment_Operators] [ 07 ] .
4444
4545## Comparison operators
4646
@@ -58,7 +58,7 @@ reference set (`-in`, `-notin`, `-contains`, `-notcontains`).
5858Type comparison operators (` -is ` , ` -isnot ` ) determine whether an object is of a
5959given type.
6060
61- For more information, see [ about_Comparison_Operators] [ 07 ] .
61+ For more information, see [ about_Comparison_Operators] [ 08 ] .
6262
6363## Logical operators
6464
@@ -77,30 +77,30 @@ work like the `Out-File` cmdlet (without parameters) but they also let you
7777redirect error output to specified files. You can also use the ` Tee-Object `
7878cmdlet to redirect output.
7979
80- For more information, see [ about_Redirection] [ 18 ]
80+ For more information, see [ about_Redirection] [ 19 ]
8181
8282## Split and join operators
8383
8484The ` -split ` and ` -join ` operators divide and combine substrings. The ` -split `
8585operator splits a string into substrings. The ` -join ` operator concatenates
8686multiple strings into a single string.
8787
88- For more information, see [ about_Split] [ 21 ] and [ about_Join] [ 12 ] .
88+ For more information, see [ about_Split] [ 22 ] and [ about_Join] [ 12 ] .
8989
9090## Type operators
9191
9292Use the type operators (` -is ` , ` -isnot ` , ` -as ` ) to find or change the .NET type
9393of an object.
9494
95- For more information, see [ about_Type_Operators] [ 22 ] .
95+ For more information, see [ about_Type_Operators] [ 23 ] .
9696
9797## Unary operators
9898
9999Use the unary ` ++ ` and ` -- ` operators to increment or decrement values and
100100` - ` for negation. For example, to increment the variable ` $a ` from ` 9 ` to
101101` 10 ` , you type ` $a++ ` .
102102
103- For more information, see [ about_Arithmetic_Operators] [ 05 ] .
103+ For more information, see [ about_Arithmetic_Operators] [ 06 ] .
104104
105105## Special operators
106106
@@ -217,7 +217,7 @@ in the body of the `if` statement.
217217### Subexpression operator ` $( ) `
218218
219219Returns the result of one or more statements. For a single result, returns a
220- [ scalar] [ 04 ] . For multiple results, returns an array. Use this when you want to
220+ [ scalar] [ 05 ] . For multiple results, returns an array. Use this when you want to
221221use an expression within another expression. For example, to embed the results
222222of command in a string expression.
223223
@@ -265,11 +265,11 @@ table. For more information, see [about_Hash_Tables][09].
265265Runs a command, script, or scriptblock. The call operator, also known as the
266266_ invocation operator_ , lets you run commands that are stored in variables and
267267represented by strings or scriptblocks. The call operator executes in a child
268- scope. For more about scopes, see [ about_Scopes] [ 19 ] . You can use this to build
268+ scope. For more about scopes, see [ about_Scopes] [ 20 ] . You can use this to build
269269strings containing the command, parameters, and arguments you need, and then
270270invoke the string as if it were a command. The strings that you create must
271271follow the same parsing rules as a command that you type at the command line.
272- For more information, see [ about_Parsing] [ 08 ] .
272+ For more information, see [ about_Parsing] [ 16 ] .
273273
274274This example stores a command in a string and executes it using the call
275275operator.
@@ -301,7 +301,7 @@ At line:1 char:2
301301 + FullyQualifiedErrorId : CommandNotFoundException
302302```
303303
304- The [ Invoke-Expression] [ 25 ] cmdlet can execute code that causes parsing errors
304+ The [ Invoke-Expression] [ 26 ] cmdlet can execute code that causes parsing errors
305305when using the call operator.
306306
307307``` powershell
@@ -341,7 +341,7 @@ PS C:\Scripts> & ".\script name with spaces.ps1"
341341Hello World!
342342```
343343
344- For more about scriptblocks, see [ about_Script_Blocks] [ 20 ] .
344+ For more about scriptblocks, see [ about_Script_Blocks] [ 21 ] .
345345
346346### Cast operator ` [ ] `
347347
@@ -353,7 +353,7 @@ converted, PowerShell generates an error.
353353```
354354
355355A cast can also be performed when a variable is assigned to using
356- [ cast notation] [ 23 ] .
356+ [ cast notation] [ 24 ] .
357357
358358### Comma operator ` , `
359359
@@ -409,7 +409,7 @@ The matching braces (`{` and `}`) are required.
409409
410410The formatting operation yields a result string that consists of the original
411411fixed text intermixed with the string representation of the objects in the
412- list. For more information, see [Composite Formatting][02 ].
412+ list. For more information, see [Composite Formatting][03 ].
413413
414414Enter the composite format string on the left side of the operator and the
415415objects to be formatted on the right side of the operator.
@@ -422,7 +422,7 @@ objects to be formatted on the right side of the operator.
4224221 hello 3.14
423423```
424424
425- You can zero-pad a numeric value with the [ "0" custom specifier] [ 03 ] . The
425+ You can zero-pad a numeric value with the [ "0" custom specifier] [ 04 ] . The
426426number of zeroes following the ` : ` indicates the maximum width to pad the
427427formatted string to.
428428
@@ -587,6 +587,19 @@ that doesn't have the member, PowerShell automatically enumerates the items in
587587that collection and uses the operator on each of them. For more information,
588588see [ about_Member-Access_Enumeration] [ 14 ] .
589589
590+ When you use the member-access operator to read a property that doesn't exist,
591+ or when a property getter method throws an exception, PowerShell returns
592+ ` $null ` instead of throwing an error. This behavior is specific to property
593+ access. This behavior follows .NET CA rule [ CA1065] [ 02 ] that states:
594+
595+ > Properties are basically smart fields. Therefore, they should behave like a
596+ > field as much as possible. Fields don't throw exceptions and neither should
597+ > properties. If you have a property that throws an exception, consider making
598+ > it a method.
599+
600+ Exceptions thrown by method invocations (including calling the underlying
601+ ` get_<PropertyName()> ` method directly) aren't suppressed.
602+
590603### Static member operator ` :: `
591604
592605Calls the static properties and methods of a .NET class. To find the static
@@ -600,34 +613,35 @@ properties and methods of an object, use the Static parameter of the
600613
601614## See also
602615
603- - [ about_Arithmetic_Operators] [ 05 ]
604- - [ about_Assignment_Operators] [ 06 ]
605- - [ about_Comparison_Operators] [ 07 ]
616+ - [ about_Arithmetic_Operators] [ 06 ]
617+ - [ about_Assignment_Operators] [ 07 ]
618+ - [ about_Comparison_Operators] [ 08 ]
606619- [ about_Logical_Operators] [ 13 ]
607620- [ about_Operator_Precedence] [ 15 ]
608621- [ about_Member-Access_Enumeration] [ 14 ]
609- - [ about_Type_Operators] [ 22 ]
610- - [ about_Split] [ 21 ]
622+ - [ about_Type_Operators] [ 23 ]
623+ - [ about_Split] [ 22 ]
611624- [ about_Join] [ 12 ]
612- - [ about_Redirection] [ 18 ]
625+ - [ about_Redirection] [ 19 ]
613626
614627<!-- link references -->
615- [ 02 ] : /dotnet/standard/base-types/composite-formatting
616- [ 03 ] : /dotnet/standard/base-types/custom-numeric-format-strings#Specifier0
617- [ 04 ] : /powershell/scripting/learn/glossary#scalar-value
618- [ 05 ] : about_Arithmetic_Operators.md
619- [ 06 ] : about_Assignment_Operators .md
620- [ 07 ] : about_Comparison_Operators .md
621- [ 08 ] : about_Parsing .md
628+ [ 02 ] : /dotnet/fundamentals/code-analysis/quality-rules/ca1065#property-get-methods
629+ [ 03 ] : /dotnet/standard/base-types/composite-formatting
630+ [ 04 ] : /dotnet/standard/base-types/custom-numeric-format-strings#Specifier0
631+ [ 05 ] : /powershell/scripting/learn/glossary#scalar-value
632+ [ 06 ] : about_Arithmetic_Operators .md
633+ [ 07 ] : about_Assignment_Operators .md
634+ [ 08 ] : about_Comparison_Operators .md
622635[ 09 ] : about_Hash_Tables.md
623636[ 12 ] : about_Join.md
624637[ 13 ] : about_Logical_Operators.md
625638[ 14 ] : about_Member-Access_Enumeration.md
626639[ 15 ] : about_Operator_Precedence.md
627- [ 18 ] : about_Redirection.md
628- [ 19 ] : about_Scopes.md
629- [ 20 ] : about_Script_Blocks.md
630- [ 21 ] : about_Split.md
631- [ 22 ] : about_Type_Operators.md
632- [ 23 ] : about_Variables.md
633- [ 25 ] : xref:Microsoft.PowerShell.Utility.Invoke-Expression
640+ [ 16 ] : about_Parsing.md
641+ [ 19 ] : about_Redirection.md
642+ [ 20 ] : about_Scopes.md
643+ [ 21 ] : about_Script_Blocks.md
644+ [ 22 ] : about_Split.md
645+ [ 23 ] : about_Type_Operators.md
646+ [ 24 ] : about_Variables.md
647+ [ 26 ] : xref:Microsoft.PowerShell.Utility.Invoke-Expression
0 commit comments