次のpowershellスクリプトを使用したいと思います:
Get-WmiObject -Class Win32_UserAccount -ComputerName . -ErrorAction Stop | where-object { $_.localAccount -eq "true" -and $_.Disabled -eq "false" -and $_.Name -cnotcontains "ASPNET"}
またはcscriptを使用して:
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
If Not IsObject(objWMIService) Or IsNull(objWMIService) Then
wscript.echo "Not an Object"
wscript.quit
End If
Set usersItems = objWMIService.ExecQuery( "SELECT * FROM Win32_UserAccount " _
& "WHERE localAccount=true and disabled=false",,48)
If Not IsObject(colItems) Or IsNull(colItems) Then
wscript.echo "Not an Object"
wscript.quit
End If