VMware Cloud Community
shaikh_h
Contributor
Contributor

VM Serve Tag

Hi all,

i have been asked to tag all our VM in side our three vCenters. i already have compile the csv file with columns heading with Name of the server, Department , Owner , Severity and Application, i am not good in powershell, can someone please help me where do i need to make changes as per Allan script at this site ""http://www.virtu-al.net/2014/11/13/automating-tags-tag-category-creation-assignment-powercli/ ""? please help me .

Thanks.

vmware-tag-question.PNG

Tags (1)
0 Kudos
4 Replies
LucD
Leadership
Leadership

If you make sure you are connected to the 3 vCenters

Connect-viserver -Server vc1,vc2,vc3 -user administrator@vsphere.local -pass Pa$$w0rd

you should be able to run Alan's script as-is.

If you have different credentials per vCenter, you could do 3 x Connect-VIServer

Connect-viserver -Server vc1 -user administrator1@vsphere.local -pass Pa$$w0rd1

Connect-viserver -Server vc2 -user administrator2@vsphere.local -pass Pa$$w0rd2

Connect-viserver -Server vc3 -user administrator3@vsphere.local -pass Pa$$w0rd3

Does that help?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
shaikh_h
Contributor
Contributor

Hi LucD,

thank you so much for your reply, i truly appreciate your reply

i have tried it as is but i am getting following error message.

================

New-TagAssignment : Cannot bind argument to parameter 'Entity' because it is null.

At line:23 char:43

+                 New-TagAssignment -entity $($_.Name) -Tag $Tagassignm ...

+                                           ~~~~~~~~~~

    + CategoryInfo          : InvalidData: (:) [New-TagAssignment], ParameterBindingValidationException

    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,VMware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.NewTagAssignment

==================

i tired to change my csv and remove all the space and add semicolon instead in between all filed as i was reading one of the blog which mention about blank space etc. but that doesn't fix my issue.

This is how my CSV file looks.

pastedImage_7.png

kindly help..

Thanks.

0 Kudos
shaikh_h
Contributor
Contributor

pastedImage_0.png

and this is how my csv out put look in PS.

0 Kudos
LucD
Leadership
Leadership

There seems to be something wrong with your CSV file.

Each line seems to be enclosed in 1 pair of quotes.

That should normally quotes around each column entry.

Something like this

"Name","Owner","Department","Application","Environment","Priority"

"server1","me","dep1","app1","prod","low"

"server2","me","dep1","app2","test","low"

You can test if your CSV is working by just doing

Import-CSV .\info.csv -UseCulture

You should then see individual fields in the output.

You can also test if it works by doing for example

Import-CSV .\info.csv -UseCulture | Select Name,Departement

Now you should only see those 2 properties in the output.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos