how to get admin local is enabled from all computers in domain

Trần Ngọc Nam 20 Reputation points
2023-02-21T09:15:28.0766667+00:00

Hi,

I have a problem with administrator local account.

Now, I can get it from computers in domain. But it enabled and disabled account.

Is there any way to only get administrator local account is still enable.
Thank for your advice.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Andreas Baumgarten 119K Reputation points MVP
    2023-02-21T12:08:30.42+00:00

    Hi @Trần Ngọc Nam ,

    you can use the cmdlet Get-LocalUser to get the details of a local user: Get-LocalUser

    # Result is $true or $false depending if the account is enabled or disabled
    (Get-LocalUser -Name "Administrator").Enabled
    
    If (((Get-LocalUser -Name "Administrator").Enabled) -eq $true){
       Write-Output "Account enabled" 
    } else {Write-Output "Account disabled"}
    

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards Andreas Baumgarten


  2. Andreas Baumgarten 119K Reputation points MVP
    2023-02-22T07:20:39.0666667+00:00

    Hi @Trần Ngọc Nam ,

    the cmdlet Get-LocalUser is part of the module Microsoft.PowerShell.LocalAccounts . In Windows 10, Windows Server 2016 and above this module is available with the Windows Management Framework by default. For Windows OS before you need to download and install the Windows Management Framework manually: Windows Management Framework 5.1


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards

    Andreas Baumgarten


  3. Andreas Baumgarten 119K Reputation points MVP
    2023-02-22T10:41:55.6133333+00:00

    Hi @Trần Ngọc Nam ,

    there are different issues based on the error messages:

    DC-ADTest-03:

    Based on the error message you should verify:

    Network connection to the machine is working properly (name resolution, machine is reachable via network). WinRM is setup properly on the machine. Firewall on the machine is configured properly to allow WinRM.

    DC-ADTest-01:

    Based on the error message you should verify:

    Use a internet search of your choice and search for winrm kerberos error 0x80090322 . There are multiple reasons/solutions for this error message.


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards

    Andreas Baumgarten


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.