Hello-
I am trying to come up with a way to search through a given list of datastores, and upon each find of a .VMX file, re-add that machine to inventory only I would like to prefix the name of the machine as something different. Ie, instead of "Machine1", I would like it to be registetred as "auto-Machine1". So imagine I have an empty datacenter with 4 datastores stored in an array $arrDatastoreToInclude,. I would like to loop through each of those datastores and add all the VMX files I find back to inventory.
I know that I can use the following to get the datastores I want:
$dsindatacenter = Get-DataCenter $DataCenterName | Get-Datastore | ?{$arrDatastoreToInclude -contains $_.Name}
But I have no idea how to scan those datastores for VMX files and what command to add them back into inventory. Can anyone help?