We help IT Professionals succeed at work.
Get Started

Mass edit a custom attribute in VMWare

Last Modified: 2015-12-22
Hi everyone.
I'm using a lot of automated RVTools scripts to obtain a lot of information about our virtual environments.
Problem is, I got into the company long after many mistakes were when people didn't thing everything through. For that reason,
Many servers are in wrong folders, and many folders are misnamed and etc.
To get some of the information I need, I have to be able to identify the client. I added a global custom attribute called "Client"
Is there a way to bulk edit this folder according to the folder?
I have PowerCli enabled and installed but I don't know it well enough to construct such a script
What I got so far is this:
# Add the vmware snapin for powershell
Add-PSSnapin VMware.VimAutomation.Core
# Your vcenter server and credentials
$vcenter = <<>><<>>
$username = <<>><<>>
$password = <<>><<>>
# Establish Connection
connect-viserver -server $vcenter -user $username -password $password
# Folder in which the Machines that are to be renamed
$Foldername = <<>><<>>
# get a list of servers from the sourceLocation
$vmservers = Get-VM -Location $sourceLocation
# Name of the client that has to be added
$clientname = <<>><<>>

Open in new window

But I can't for the life of me figure out how to loop through the servers and update that custom property.
Any help?
Watch Question
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE