Null-valued expression
Documentation: Microsoft Learn
Work the problem
A lookup found no row
Fictional case: A filtered query returns zero records. The next line calls a method on the result and fails.
Reasoning notebook
Record the evidence that supports your answer and the check you would run next. Your notes stay in this browser — nothing is uploaded.
Why it happens
A cmdlet that finds nothing returns nothing rather than raising an error, so the following line operates on $null and only fails when it tries to reach inside. Strict mode is off by default, which means a misspelled property name also evaluates quietly to $null. Two different root causes produce the identical message.
Check this first
What to look for
The method failure is downstream of the empty lookup. Decide whether no match is expected or a failed requirement.
Working through it
- Read the full record with $Error[0] | Format-List * -Force and note the line number and invocation details.
- Isolate the failing expression on its own line and test it with $null -eq to learn whether the object or the property is the missing piece.
- Confirm the property name against Get-Member rather than against what the console displayed.
- Add Set-StrictMode -Version Latest so referencing a nonexistent property becomes an error where it happens.
- Guard the call with an if test or the null-conditional operator so a legitimately empty result stops becoming an exception.
Avoiding it next time
Verify the repair: Test zero, one and multiple matches, and confirm each produces the intended result or an explicit failure.
Primary documentation
Work through the incident
Trace a missing object
A script fails when it calls a method on an expected result.
The sandbox is visible now. Sign in with Google only when you run or check a task; commands and temporary files are discarded when you leave.
Run a command to inspect its result.