Powecli Tags, Customattributes, Notes

One of the main known issues in vCenter or even any object managements is the mess that can collected so fast if you are not managing your VM’s, Objects, so thoroughly, you see oldest objects and always put in your mind that you will clean it, and honestly you are not reaching that and meantime the garbage is made by everyone, un-managed and uncontrolled environment is unstable environment.
In this quick procedure i am going to share some useful PowerCli commands that will help you make a tidy on your vCenter environment which including importing the following values using PowerCli Tags, Custom attributes, Notes

 

How to import tag of “VM Onwer” using Powercli:
Updating  “CustomAttribute”

My Excel must contain VM name and VMOwner columns:

$vms = Import-Csv C:\VMlist.csv
vms | foreach {
$vm = $_.name
$owner = $_.VMOwner

Set-Annotation -Entity $vm -CustomAttribute "VM Owner" -Value $owner }


How to add notes to your Virtual Machines from CSV:
Also here, your Excel can contains only two volumes, VM lists.

$vms = Import-Csv C:\VMlist.csv


$vms | foreach {
$vm = $_.name
$notes = $vms.notes
 Set-vm -vm $vm -Description $notes -Confirm:$false }

Updating Tags:

The following commands can help you with importating tags to your VM’s, your Excel

$vms = import-csv C:\VMlist.csv

$vms | foreach {
$vm = $_.Name
$tag = $_.tag

New-TagAssignment -Tag $tag -Entity $vm

}

Leave a Comment

Your email address will not be published.

Comment moderation is enabled. Your comment may take some time to appear.

In the news
Load More