Check if account exists

Peter_1985 2,586 Reputation points
2022-11-02T03:39:12.653+00:00

Hi,
To the code like
Dim computer
Set computer = GetObject("WinNT://" & computerName)
Dim user
Set user = computer.Create("user", userName)
user.SetPassword password
user.SetInfo
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
    2022-11-03T08:32:06.96+00:00

    Hi,

    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.

    Get-LocalUser
    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--