Author Posts

June 19, 2017 at 2:04 pm

when I run the above mentioned script in server 2008 (powershell v1.0), I am not getting output with the local user name...pls let me know if you can assist me in that...

But its working fine in 2008R2 and also in 2012.

$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$adsi.Children | where {$_.SchemaClassName -eq 'user'} | Foreach-Object
{$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
$_ | Select-Object @{n='UserName';e={$_.Name}},@{n='Groups';e={[string]::Join(';',$groups)}}

June 20, 2017 at 1:18 pm

v1 didn't implement an [ADSI] accelerator, I don't think.

June 20, 2017 at 2:02 pm

Thanks for clarifying that Don. Guess those servers needed to be updated to v2.0 or use wmi to get that result.