lundi 8 mars 2021

Powershell - If Statement Output 2 values

Iam trying to write a script to notify if a VMware VM Custom attribute has a value or if the value is null. I need the VM name and the Output Value (either Null or Not Null). Here is what I have but doesn't return the accurate information

$vms = Get-VM

foreach ($vm in $vms) {

    $tag = $vm | Get-Annotation -CustomAttribute "Backup"
   
    if ($tag.value -eq '$null'){
        Write-Output "$vm Attribute doesnt have a value"
    }
    else {
        Write-Output "$vm Attribute has a value assigned"
    }
}

Aucun commentaire:

Enregistrer un commentaire