Sample script to set VM tags in the guestinfo
This commit is contained in:
@@ -80,13 +80,13 @@ ForEach ($categoryName in $Categories) {
|
|||||||
# Get Tag assignments for the VMs
|
# Get Tag assignments for the VMs
|
||||||
$tags = Get-TagAssignment -Entity $VMs -Category $category
|
$tags = Get-TagAssignment -Entity $VMs -Category $category
|
||||||
|
|
||||||
# Group the tags by VM (in this case the Entity property of Group-Object)
|
# Group the tags by VM (in this case the Entity property of Group-Object)
|
||||||
$groups = $tags | Group-Object -Property Entity
|
$groups = $tags | Group-Object -Property Entity
|
||||||
|
|
||||||
# Get each VM and set the guestinfo
|
# Get each VM and set the guestinfo
|
||||||
ForEach ($item in $groups) {
|
ForEach ($item in $groups) {
|
||||||
$vm = get-vm $item.Name
|
$vm = get-vm $item.Name
|
||||||
# Multiple tags of the same category are joined
|
# Multiple tags of the same category are joined
|
||||||
$guestinfoValue = $item.Group.Tag.Name -join $Delimiter
|
$guestinfoValue = $item.Group.Tag.Name -join $Delimiter
|
||||||
|
|
||||||
Write-Host "$($vm): setting '$guestinfoName' = '$guestinfoValue'"
|
Write-Host "$($vm): setting '$guestinfoName' = '$guestinfoValue'"
|
||||||
|
|||||||
Reference in New Issue
Block a user