Check if account exists

Peter_1985 2,586 Reputation points

To the code like
Dim computer
Set computer = GetObject("WinNT://" & computerName)
Dim user
Set user = computer.Create("user", userName)
user.SetPassword password
how to ensure that the relevant account does not exist on that machine?

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
915 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,664 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,081 Reputation points


    The Get-LocalUser PowerShell cmdlet lists all the local users on a device. Remember that Active Directory domain controllers don’t have local user accounts.

    If you want to see all the parameters available, pipe the results to the Select cmdlet:

    Get-LocalUser | Select *
    Running the cmdlet without any parameters returns all accounts but you can also add the -Name or -SID parameters to return information about a specific account.

    I hope this answers your question.


    --If the reply is helpful, please Upvote and Accept as answer--