Check if a string is not NULL or EMPTY
You don't necessarily have to use the [string]:: prefix. This works in the same way:
if ($version)
{
$request += "/" + $version
}
A variable that is null or empty string evaluates to false.
if (-not ([string]::IsNullOrEmpty($version)))
{
$request += "/" + $version
}
You can also use !
as an alternative to -not
.