def get_object_by_name(content, object_type, name, regex=False):
container = content.viewManager.CreateContainerView(<EOL>content.rootFolder, [object_type], True<EOL>)<EOL>for c in container.view:<EOL><INDENT>if regex:<EOL><INDENT>if re.match(name, c.name):<EOL><INDENT>return c<EOL><DEDENT><DEDENT>elif c.name == name:<EOL><INDENT>return c<EOL><DEDENT><DEDENT>
Get the vsphere object associated with a given text name
Source: https://github.com/rreubenur/vmware-pyvmomi-examples/blob/master/create_template.py