Avatar of David Sankovsky
David Sankovsky
Flag for Israel asked on

Mass edit a custom attribute in VMWare

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?
VMwarePowershellShell Scripting

Avatar of undefined
Last Comment
David Sankovsky

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
David Sankovsky

Thanks, I'll check that in a few minutes and will update you
David Sankovsky

That solved it, thanks a lot.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes