Learn about Windows PowerShell
Summary: Here is the answer to the third question in Mini-Scripting Games 2014.
You are writing a script, and when it runs, you receive an error message that states: “You cannot call a method on a null-valued expression." What is the first thing you should check?
Check the code that creates the object that you stored in the variable. It is probable that there is a problem with that code. For example, let's say I read from a database and store the results from that database to a variable, and then I call the MoveNext() method.
If I get an error message that tells me I cannot call a method on a null-valued expression, it means that I did not successfully connect to the database or I did not return a record set from the database.
This could be due to an invalid query or a query that returned no rows from the database.
Or you try to invoke a method of a variable in a workflow?