Thanks @LucD for the fantastic script. It works perfectly but has a problem. The value of NB_LAST_BACKUP gets updated on every backup but the script is unable to update the new value on re-run as the cardinality is single and if we set it multiple, then there will be multiple values added to the VM. In that case, can you update the script so the existing tag is removed before tagging the new value? Also is there any command that can be used to delete all the tags without assignment? it will help me delete all the unnecessary tags that are created every day with the date format which will not be used again.
Get-TagAssignment -entity $Vm -Category LastBackupDate |Remove-Tagassignment -Confirm:$false