IF([string]::IsNullOrEmpty($mystring)) { Write-Host "Given string is NULL or EMPTY" } else { Write-Host "Given string has a value" }
Both the methods described above gives you the same functionality. But if you want more meaningful and neat look to your code, I would prefer the second method.
Read full article from Check if a string is NULL or EMPTY using PowerShell
No comments:
Post a Comment