Link to home
Start Free TrialLog in
Avatar of David Sankovsky
David SankovskyFlag 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?
ASKER CERTIFIED SOLUTION
Avatar of SreRaj
SreRaj
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Sankovsky

ASKER

Thanks, I'll check that in a few minutes and will update you
That solved it, thanks a lot.