I’m working on a collection of scripts to check and update the members of local groups across a range of servers following Richard’s excellent example available on the Hey, Scripting Guy! blog. Everything is fine save for the fact that each of the commands takes forever to run. I’ve tried the following on a number of 2012 R2 and 8.1 workstations on the domain:
$group = Get-CimInstance -ClassName Win32_Group -Filter "Name = 'Administrators'" Get-CimAssociatedInstance -InputObject $group -ResultClassName Win32_UserAccount | select -ExpandProperty Caption
All of the machines are of a decent specification and connected directly to the LAN but regardless of which one I choose Measure-Command reports an average run time of around 20 minutes. It’s the same whether I go for the CIM approach, the WMI approach or the AccountManagement class approach.
Can anyone suggest what I might be doing wrong?
Many thanks in advance.