So I've seen this code posted several times around the web
- ([ADSI]("WinNT://PCNAME/Administrators,group")).Invoke('Members') |
- ForEach-Object {
- ($_.GetType()).InvokeMember('ADspath', 'GetProperty', $null, $_, $null).Replace('WinNT://', '')
- }
Why it takes so long somtimes? Is there a better version without using GWMI? ( we have a current build problem with Get-WmiObject will fail )
I've also had some inconsistencies such as:
Error while invoking GetType. Could not find member.
At line:3 char:9
+ ($_.GetType()).InvokeMember('ADspath', 'GetProperty', $null, ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], MissingMemberException
+ FullyQualifiedErrorId : System.MissingMemberException
There are all lan connected PCs that are in our general OU that should have 3 local admins. I get this error twice,then it will display one of the three local admins, then one more error.
There is nothing else to this script as of now.