ADSI to get local users

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of VT VT 6 days, 15 hours ago.

  • Author
  • #73189
    Profile photo of VT

    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)}}
  • #73286
    Profile photo of Don Jones
    Don Jones

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

    • #73295
      Profile photo of VT

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

You must be logged in to reply to this topic.