Я начал переписывать свой ежедневный отчет VMware, чтобы использовать Get-View, а не соответствующие команды PowerCLI, где это возможно, из соображений производительности. Одно небольшое неудобство заключается в том, что возвращаемые объекты представления часто имеют много свойств, многие из которых сами являются объектами. Некоторые свойства вложены в четыре или более уровней.
Итак, я пытаюсь создать функцию, которая будет выводить все свойства объекта вместе с полным путем к этому свойству. Затем его можно передать по конвейеру в Where-Object, чтобы упростить поиск определенных свойств. Итак, чтобы найти свойство, относящееся к Host в объекте VMware.Vim.VirtualMachine, хранящемся в $ v, я бы набрал что-то вроде:
Get-Properties -Object $v | ? {$_ -match "Host"}
И в идеале это должно вернуть список всех вложенных свойств $ v, которые содержат слово «Host».
Как я могу это сделать?