Search code examples
.netstringpowershellnull

How can I check if a string is null or empty in PowerShell?


Is there a built-in IsNullOrEmpty-like function in order to check if a string is null or empty, in PowerShell?

I could not find it so far and if there is a built-in way, I do not want to write a function for this.


Solution

  • You can use the IsNullOrEmpty static method:

    [string]::IsNullOrEmpty(...)