I can’t test for a null or empty string with Pester


I need to test for a Null or empty string but my test fails with the following error.


Make sure you use “Should BeNullOrEmpty” and not “Should Be NullOrEmpty”.


When I originally wrote the test I wrote the assert like this:

$result | Should Be NullOrEmpty

Which resulted in the error I showed above.  Removing the space between Be and NullOrEmpty now passes as expected.

$result | Should BeNullOrEmpty

Add comment