Hello,
is it possible to get a tag that has been assigned to a specific VM?
Backround is, that I want to configure 4 Uninterruptible Power supplies in 4 different rooms to run a script when the power goes down. Basically if the power in one building goes down it should run a script on the esx-server to move all the running VM´s on to the esx-server to a room in the other building.
I thought that it would be practical to make a tag on each VM with the information where to it should be moved when the power goes out. That way I can dynamically say VM001 is going to be moved on one esxserver and VM002 on another, without changing the script itself too much.
like for example:
VM001 (a vm on ESXSERVER1)
Category: BackupESXSERVER
TAG: ESXSERVER2 (so if the power goes out for ESXSERVER1 and it runs on the UPS, it should be moved to ESXSERVER2)
But how to I read which tag has been assigned to the VM from the category "BackupESXSERVER"?
get-tag -category BackupESXSERVER -VM ????
I can´t find a solution in the documentation. Is there a way?
You have to use the Get-TagAssignment cmdlet to retrieve the tag assignment. For example:
Get-VM -Name VM001 | Get-TagAssignment -Category BackupESXSERVER | Select-Object -ExpandProperty Tag | Select-Object -ExpandProperty Name
You have to use the Get-TagAssignment cmdlet to retrieve the tag assignment. For example:
Get-VM -Name VM001 | Get-TagAssignment -Category BackupESXSERVER | Select-Object -ExpandProperty Tag | Select-Object -ExpandProperty Name
Thanks! This should do it.
I´m going to test it today.