I have been watching some CBT Nuggets on PowerShell recently and in one of them the instructor says that utilizing ForEach-Object
should be a last resort with using available cmdlets
and WMI Methods
first. So, my question is what would be the most efficient way to get a property from multiple objects of the same type? For example:
would this:
(Get-ADComputer -Filter *).Name
be more efficient than this:
Get-ADComputer -Filter * | ForEach-Object {$_.Name}
and how do these function differently from each other?