We are on ZENworks 2017 2a and I am working on a Powershell preboot script for WinPE imaging that will check if the computer has a name in image safe data. If it does then it will ask to keep the existing name or allow the user to enter a new one. If not, then it will prompt "No image safe data found" and it will require a name. I mirrored logic that we have been using for years in the Linux environment and it worked fine for all cases. However that logic is not working in WinPE using Powershell. Here is the code I am using (see code in blue since this is where the problem is):

$ZISNAME= zisview ComputerName

If (!$ZISNAME)

{
Do
{
Write-Host ""
Write-Host "No Zenworks image-safe data found. A workstation name is required to continue." -ForegroundColor White -BackgroundColor Red
Write-Host ""
$WSNAME = Read-Host -Prompt "Enter the workstation name"
Get-Variable WSNAME -ValueOnly
if($WSNAME)
{
zisedit ScriptedImage=True
zisedit ComputerName=$WSNAME
zisedit dnsHostname=$WSNAME
#zisedit netbiosName=$WSNAME #Not needed, changed by ComputerName
$ZISNAME= $WSNAME
Write-Host "The workstation name is $ZISNAME"
Write-Host ""
}

elseif (!$WSNAME)
{
$ZISNAME= $null
}

}
While(!$ZISNAME)
}


ElseIf ($ZISNAME)
{
Write-Host ""
Write-Host ""
Write-Host "Computer Name: $ZISNAME"
Write-Host ""
$WSNAME = Read-Host -Prompt "Change Name (Enter Name to change,press Enter to keep existing)"
Get-Variable WSNAME -ValueOnly
if ($WSNAME)
{
Write-Host "Name Changed to $WSNAME"
Write-Host ""
zisedit ScriptedImage=True
zisedit ComputerName=$WSNAME
zisedit dnsHostname=$WSNAME
$ZISNAME= $WSNAME
}
}



If I use If(!ZISNAME) then it doesn't account for no image safe data. It shows computer name is: <blank> then asks to enter a new name. So if I run zisedit -c then run the script, it thinks no data is a name because the value is not null. If I set ZISNAME to $null at the beginning of the script or enter any value then the script works fine.

If I use If(ZISNAME= " ") then it does not accept a new name but keeps whatever name is entered and continues on with the script. There is a space between the quotes.

If I use If(ZISNAME="") then it skips asking for a name and goes right to installing the image.

So using !ZISNAME would be the best option but I don't know how to account for a blank name since it is technically not null. Any ideas?