VMware Cloud Community
rkuechler
Enthusiast
Enthusiast
Jump to solution

Retrieve a "VC:HostSystem" object from an ESXi hostname FQDN (string value)?

Hi

Has anybody an idea, how to get a "VC:HostSystem" object from a single ESXi host FQDN string?
Probably no rocket science, but (still as a rookie) I can't figure it out - and can't find anything as well. 🙁

Thanks in advance and regards

Roman

 

Addendum: Currently, I simply loop through an object with all ESXi hosts of the vCenter, until the name matches with the host I'm looking for. Maybe this is allready the best solution...?

Reply
0 Kudos
1 Solution

Accepted Solutions
mayank_goyal
Enthusiast
Enthusiast
Jump to solution

var xpath = "xpath:matches(name, '(?i)" + hostFqdn + "')" //Case-insensitive match
var hosts = VcPlugin.getAllHostSystems(null, xpath);
return hosts[0];

mayank_goyal_0-1686724717606.png

 

 



-
For more interesting content on Aria Automation, check my blog:
https://cloudblogger.co.in

View solution in original post

3 Replies
mayank_goyal
Enthusiast
Enthusiast
Jump to solution

var xpath = "xpath:matches(name, '(?i)" + hostFqdn + "')" //Case-insensitive match
var hosts = VcPlugin.getAllHostSystems(null, xpath);
return hosts[0];

mayank_goyal_0-1686724717606.png

 

 



-
For more interesting content on Aria Automation, check my blog:
https://cloudblogger.co.in
rkuechler
Enthusiast
Enthusiast
Jump to solution

Works very well!

Thanks a  lot.

Reply
0 Kudos
mayank_goyal
Enthusiast
Enthusiast
Jump to solution

Thanks for taking the suggestion. Please marked it resolved if it works for you.



-
For more interesting content on Aria Automation, check my blog:
https://cloudblogger.co.in
Tags (1)
Reply
0 Kudos