Вывести список пользователей windows командная строка

Windows — многопользовательская система, что означает, что в ней могут относительно независимо работать несколько пользователей. Помимо пользовательских учетных записей, создаваемых при установке и после, в системе предусмотрено несколько скрытых системных учетных записей. При необходимости вы можете получить список и тех и других.

В этой простой инструкции подробно о способах посмотреть список пользователей Windows 11 или Windows 10, большинство из которых подойдёт и для предыдущих версий системы. Если вам требуется получить список пользователей без входа в систему, обратите внимание на последний раздел этого материала.

Windows PowerShell или Терминал Windows

Если по той или иной причине вам потребовалось получить список всех пользователей Windows 11, Windows 10 или одной из предыдущих версий системы — сделать это можно как в графическом интерфейсе, так и средствами командной стройки или PowerShell.

Я рекомендую начать с PowerShell, так как он позволяет быстро получить максимум информации об учетных записях пользователей:

  1. Запустите Windows PowerShell или Терминал Windows от имени администратора, для этого можно нажать правой кнопкой мыши по кнопке «Пуск» и выбрать нужный пункт контекстного меню.
  2. Введите команду
    Get-LocalUser

    и нажмите Enter.

  3. В результате вы получите полный список учетных записей пользователей, а также информацию, включена ли учетная запись в столбце «Enabled».
    Получение списка пользователей в PowerShell

Обратите внимание, некоторые учетные записи могут вызвать вопросы, ответы на них можно найти в статьях:

  • Как включить скрытую системную учетную запись Администратор в Windows 11 (подойдет и для Windows 10)
  • Для чего нужна учетная запись WDAGUtilityAccount в Windows 11/10

Командная строка

Список пользователей Windows можно получить с помощью командной строки:

  1. Запустите командную строку (права администратора не обязательны).
  2. Введите команду
    net user

    и нажмите Enter, чтобы получить список всех пользователей.

    Команда net user в командной строке

  3. Ещё одни вариант команды:
    wmic useraccount get name
    Получение списка пользователей в командной строке

Оба варианта отобразят как активных, так и отключенных (скрытых) пользователей, но без информации, о том, что это за учетная запись и включена ли она. Второй вариант команды допускает следующую модификацию:

wmic useraccount get name,status

для просмотра информации о статусе учетных записей (для включенных — Ok, для отключенных — Degraded).

Параметры Windows 11 и Windows 10

«Основной», но не идеальный метод просмотра списка пользователей в графическом интерфейсе — приложение «Параметры»:

  1. Откройте «Параметры».
  2. В Windows 11 откройте раздел «Учетные записи» — «Другие пользователи» для того, чтобы посмотреть список пользователей, помимо текущего (и без отключенных и системных учетных записей).
    Список пользователей в параметрах Windows 11

  3. Если вы используете семейную группу (например, для родительского контроля Windows), пользователи, добавленные в семью, будут показаны не в «Другие пользователи», а в «Учетные записи» — «Семья».
    Члены семьи в параметрах Windows 11

  4. В Windows 10 откройте «Параметры» — «Учетные записи» — «Семья и другие пользователи». На открывшемся экране будут показаны пользователи компьютера (за исключением текущего), а также члены семейной группы при их наличии.
    Список пользователей в Параметрах Windows 10

Как в Windows 11, так и в Windows 10 в «Параметрах» вы не увидите отключенные учетные записи.

Локальные пользователи и группы

Ещё один вариант просмотра пользователей в графическом интерфейсе — оснастка «Локальные пользователи и группы».

  1. Нажмите клавиши Win+R на клавиатуре, либо нажмите правой кнопкой мыши по кнопке «Пуск» и выберите пункт «Выполнить». Введите lusrmgr.msc в диалоговое окно «Выполнить» и нажмите Enter.
  2. В открывшемся окне «Пользователи» вы сможете посмотреть список пользователей текущей системы, их статус (если рядом со значком отображается стрелка — пользователь отключен).
    Список пользователей в локальные пользователи и группы

  3. Дважды нажав по учетной записи пользователя, можно изменить её параметры (например, включить или отключить пользователя) и посмотреть описание.
    Настройка пользователей в локальные пользователи и группы

Некоторые дополнительные детали, которые могут пригодиться в части получения списка пользователей:

  • Если при использовании способов получения списка пользователей в командной строке или PowerShell вам требуется вывести список в файл, просто добавьте «> путь_к_файлу» через пробел после команды, например:
    wmic useraccount get name,status > spisok.txt

    Учитывайте, что путь (папка) в которую сохраняется файл должен существовать, а если для сохранения файла в указанном расположении требуются права администратора, консоль следует запускать с соответствующими правами.

  • При необходимости получить список пользователей без входа в систему в случае, если он невозможен, либо если система не запускается, вы можете использовать утилиты с WinPE, те же самые, которые описаны в последней части инструкции про сброс пароля Windows 11 (подойдет и для других версий системы).

Если у вас остаются вопросы, касающиеся просмотра списка пользователей Windows, вы можете задать их в комментариях ниже, описав ситуацию и задачу в деталях.

Содержание статьи:

  • Просмотр списка пользователей
    • Способ 1
    • Способ 2
    • Способ 3
    • Способ 4
    • Способ 5
  • Вопросы и ответы: 0

Вводная (описание задачи): при диагностике и настройке ОС Windows иногда требуется посмотреть всех пользователей, которые есть в системе (кстати, среди них  могут быть и скрытые учетные записи, которые вы сами не создавали). Сделать это можно разными способами, некоторые из них приведу ниже.

*

Примечание: в заметке приведены как универсальные способы, так и сугубо для современных Windows 10/11. Если у вас не работает один из них — попробуйте другой!

*

Просмотр списка пользователей

Способ 1

  1. нажать Win+R, чтобы появилось окно «Выполнить» (как на скрине ниже);
  2. ввести команду compmgmt.msc и нажать Enter (прим.: эта команда откроет окно управления компьютером);

    img-compmgmt.msc-----upravlenie-kompyuterom.png

    compmgmt.msc — управление компьютером

  3. далее необходимо открыть вкладку «Локальные пользователи и группы -> Пользователи»: в ней будет представлен весь список пользователей + описание;

    img-Lokalnyie-polzovateli-i-gruppyi.png

    Локальные пользователи и группы

  4. если какая-то учетная запись вам не нужна — ее можно удалить (для вызова соотв. опции — просто нажмите по учетной записи правой кнопкой мыши…). Важно: при удалении учетной записи — все файлы и документы, которые были с ней связаны, тоже будут удалены! См. скрин ниже. 👇

    img-SHHelchek-PKM-dlya-udaleniya-nenuzhnoy-uchetnoy-zapisi.png

    Щелчок ПКМ для удаления ненужной учетной записи

*

Способ 2

  1. сначала открыть командную строку от имени администратора (Win+R, команда CMD и нажать Ctrl+Shift+Enter);
  2. в открывшемся «черном окне» необходимо ввести net user и нажать Enter. Далее увидите список всех пользователей (см. рис. ниже).

    img-komanda-net-user-pokazhet-polzovateley.png

    команда net user покажет пользователей \\ командная строка

  3. кстати, можно воспользоваться и др. командой: wmic useraccount get name,status

    img-Polzovat-status-komandnaya-stroka.png

    Пользовать + статус (командная строка) // Статус Degraded обычно означает, что учетная запись существует, но вход в систему не выполнен (т.е. учетная запись ∼откл.).

*

Способ 3

  1. открываем терминал (можно кликнуть ПКМ по меню ПУСК…);

    img-PKM-po-pusku-terminal.png

    ПКМ по пуску — терминал

  2. далее вводим команду Get-LocalUser и нажимаем Enter: через 1-2 сек. получаем список (с описанием и статусом).

    img-Terminal-Windows-Get-LocalUser.png

    Терминал Windows — Get-LocalUser

*

Способ 4

  1. открываем параметры системы Windows 10/11 (обычно, достаточно нажать сочетание Win+i);
  2. переходим в раздел «Учетные записи / другие пользователи» (также можно заглянуть во вкладку «Семья», см. рис. ниже 👇);

    img-Parametryi-sistemyi-Windows-11-----uchetnyie-zapisi.png

    Параметры системы Windows 11 — учетные записи

  3. обратите внимание, что Windows покажет только активных пользователей (т.е. учетные записи со статусом «OK». Других пользователей — см. предыдущими способами).

    img-Drugie-polzovateli.png

    Другие пользователи

*

Способ 5

  1. сначала потребуется открыть контрольную панель (Win+R, команда control);
  2. далее перейти в раздел «Учетные записи пользователей»;

    img-Kontrolnaya-panel-uchetnyie-zapisi-polzovateley.png

    Контрольная панель — учетные записи пользователей

  3. в нем будет ссылка «Управление другой учетной записью» — делаем по ней ЛКМ;

    img-Upravlenie-drugoy-uchetnoy-zapisyu.png

    Управление другой учетной записью

  4. ву-а-ля! Список активных учетных записей перед нами… Кстати, из этого же окна вы можете изменить имя учетной записи, ее пароль, тип (и даже удалить!).

    img-Upravlenie-uchetnyimi-zapisyami.png

    Управление учетными записями

*

Дополнения и комментарии по теме — можно оставить через спец. форму ниже. 

Всего доброго!

👋

Sometimes, you may need to extract a list of all the user accounts on a Windows computer. What if you want to see all the hidden user accounts that exist alongside your user account? Can you use graphical tools in Windows to learn all that? Can you list all users with Windows’ CMD? Moreover, which Windows PowerShell CLI command can be used to list the users within local groups on a given computer? These are all answers you might need, so to help you out, here are seven methods you can use to see all the users in Windows:

NOTE: This guide covers Windows 11 and Windows 10. Most instructions are the same in both operating systems, so I’m mainly using screenshots from Windows 11. When things differ, you’ll find separate sections for Windows 11 and Windows 10.

1. How to list all users in Windows’ CMD (or PowerShell)

This method works both in the Command Prompt and PowerShell. Open the command-line app that you prefer, and run this command:

net user

After you press Enter on your keyboard, the net user command lists the users that have accounts configured on a Windows PC, including hidden ones or disabled user accounts. The user accounts are listed by their internal names that Windows uses behind the scenes, not by their full display name, seen when you sign in to Windows.

Run net user to make Windows CMD show users

Run net user to make Windows CMD show users

You can also ask the net user command to store the list of users in a text file that opens in Notepad or any other text editor. To do that, specify the file name after the command, like this:

net user > filename.txt

Then, a file with the name you provided is created under “C:\Users\Your User Name.”

Save the net list of users to a file using net user

Save the net list of users to a file using net user

If you want to export the CMD list of users to a text file that’s saved in a location you choose, run the net user command like this:

net user > «path\filename.txt»

Export the CMD list of users to a file at a specified location

Export the CMD list of users to a file at a specified location

A neat trick is using this command to find information about a specific user account. You can do it using the command like this:

net user username

Once you press Enter, Windows displays helpful information about that user account, like the date its password was last set, when it expires (if it’s set to expire), and the groups it’s a part of.

Getting details about a user account in CMD, using the net user command

Getting details about a user account in CMD, using the net user command

If you want to know more about this command and all its parameters, access this documentation page: Net user command.

2. How to use PowerShell to get all users on a computer

PowerShell offers an alternative way of finding all the users on your computer. If this is your favorite CLI (command-line interface), you might prefer using the next commands:

2.1. Which Windows PowerShell CLI command can be used to list the users on a given computer?

While you can also use the net user command in PowerShell, the best command to view all users in Windows 11 and Windows 10 in this CLI is:

get-localuser

Using PowerShell to get all users on a computer

Using PowerShell to get all users on a computer

Another alternative is to use this command:

Get-WmiObject Win32_UserAccount -filter «LocalAccount=True» | Select-Object Name,FullName,Disabled

An alternative way to list all users in PowerShell

An alternative way to list all users in PowerShell

However, if you have many user accounts configured on your computer, this command is slower than the get-localuser one.

2.2. Which Windows PowerShell CLI command can be used to list the users within local groups on a given computer?

In addition to the get-localuser command, PowerShell also offers another command that I think you might find useful: Get-LocalGroupMember. This command allows you to list all the users from a local group on your PC. For instance, if you’d like to see what other users are administrators on your Windows computer, you can run the command like this:

Get-LocalGroupMember -Group «Administrators»

List local group members in PowerShell

List local group members in PowerShell

Replace the Administrators group in my example with any other group to list its users. And by the way, if you need to see the local user groups configured on your PC, you can run this command:

Get-LocalGroup

Command to see local groups

Command to see local groups

Now that we’ve seen the PowerShell CLI commands for listing users let’s move on to the easier methods. And by easier, I mean graphical. 🙂

3. How to see the list of all user accounts in Computer Management

A click-or-tap method that displays all user accounts, including hidden users or disabled ones, involves using Computer Management. Open Computer Management, and go to Local Users and Groups > Users. On the right side, you get to see all the user accounts, their names as used by Windows behind the scenes, their full names (or their display names), and, in some cases, a description as well.

Windows list of users displayed in Computer Management

Windows list of users displayed in Computer Management

Double-click or double-tap on a user account to learn more about its properties and settings, including the user groups that it is part of.

4. How to see the list of active user accounts in Windows 11’s Settings

If all you want is to find out who are the active users of your Windows 11 PC, you don’t actually need to use the command-line or advanced snap-ins like Computer Management. You can simply see them in the Settings app. Press Win + I on the keyboard to launch it, select Accounts on the left sidebar and click or tap Other users on the right side of the app.

Head to Other users in Settings' Accounts section

Head to Other users in Settings’ Accounts section

Then, you can see the list of users with access to your Windows 11 computer beside you.

See the list of active users in Windows 11

See the list of active users in Windows 11

The drawback of this method is that it doesn’t tell you anything about hidden or disabled user accounts.

5. How to see the list of active user accounts in Windows 10’s Settings

Windows 10 also lets you find the active user accounts on your computer without having to run commands or use the advanced Computer Management application. You can simply use Settings for that. Open the Settings app (a quick way is to click on its Start Menu button), and head to Accounts.

Go to Accounts in Windows 10's Settings

Go to Accounts in Windows 10’s Settings

Select Family & other users on the left sidebar and check the list of active users on your PC on the right. You’ll find all of them listed under Other users.

See the list of active users in Windows 10

See the list of active users in Windows 10

The disadvantage of using this method is that it doesn’t show you hidden or disabled user accounts.

6. How to see the list of active user accounts using the Control Panel

An old-fashioned method that you can use to get the list of active user accounts involves opening the Control Panel. After launching it, go to User Accounts.

The User Accounts entry from the Control Panel

The User Accounts entry from the Control Panel

Then, click or tap on User Accounts.

Opening the User Accounts settings

Opening the User Accounts settings

You now see your user account, information about it, and several links. Click or tap the “Manage another account” link.

Manage another account

Manage another account

Now you see the active, not-hidden user accounts in Windows, whether they are local accounts, administrators, etc.

Control Panel shows the list of users on a Windows computer

Control Panel shows the list of users on a Windows computer

With this method, you cannot see hidden or disabled user accounts either.

7. How to see the list of active user accounts on the Windows sign-in screen

The obvious and most straightforward method is to look at the sign-in screen before logging into Windows. On this screen, you should see all the active (not hidden) user accounts that exist in Windows. Both in Windows 11 and Windows 10, this list is shown in the bottom-left corner of the sign-in screen.

Windows list of users shown on the sign-in screen

Windows list of users shown on the sign-in screen

The downside of this method is that you cannot see hidden or disabled user accounts.

Did you find many hidden user accounts on your Windows PC?

We highly recommend trying the first three methods for identifying all the user accounts that exist on your Windows computer or device. You may be surprised to see that some of your apps created hidden user accounts that you had no idea existed. Before closing this tutorial, share in a comment whether you found hidden user accounts on your PC and how many of them were there. We are curious to know, so tell us your story.

To list users in the Command Prompt (CMD) on a Windows system, you can use the `net user` command, which displays a list of all user accounts currently on the computer.

Here’s the command in markdown format:

net user

What is CMD?

CMD, or Command Prompt, is a command-line interpreter available in most Windows operating systems. It allows users to execute commands to perform various administrative functions, manage files, and run applications. CMD is particularly powerful for users who prefer text-based interactions and those who need to automate tasks through scripting.

List Disks in Cmd: A Quick Guide to Disk Management

List Disks in Cmd: A Quick Guide to Disk Management

Importance of Managing Users in CMD

Managing user accounts effectively is crucial for system administrators, developers, and tech enthusiasts alike. Understanding how to list users in CMD can help with:

  • Monitoring user activity: Keep track of who has access to the system and their permissions.
  • Troubleshooting: Quickly identify account-related issues that may affect performance or security.
  • System management: Streamlining the user creation and deletion processes.

List Folders in Cmd: A Quick Guide to Navigation

List Folders in Cmd: A Quick Guide to Navigation

How to List Users in CMD

Basic Command to Show Users

The most straightforward way to list users in CMD is by using the `net user` command. This command displays a list of all user accounts on the system.

net user

When you execute this command, you’ll receive a list that includes both the names of all user accounts and some basic information about them. Each name corresponds to a user account on the machine, and you can delve deeper into specific accounts if needed.

Filtering and Formatting User Lists

Listing Specific User Details

To obtain detailed information about a specific user account, you can extend the command by inputting the username.

net user [username]

Replace `[username]` with the actual username you wish to examine. The output will include extensive details such as the full name, account status, group memberships, and the last time the user logged on. This information can be invaluable for administrative purposes.

Formatting for Readability

If you wish to save the list of users to a file for easier reading or sharing, you can redirect the output of the command with a simple syntax:

net user > users.txt

This command creates a text file named `users.txt` in the current directory containing the list of user accounts. Opening this file will provide you with a clear view of all users, free from the clutter of CMD.

Using WMIC to Get User Information

Alternatively, you can utilize the Windows Management Instrumentation Command-line (WMIC) to gather user information. This method may provide additional flexibility in querying user details.

wmic useraccount get name

Upon execution, this command will return a clean list of all user accounts on the system. WMIC allows users to query more complex datasets and offers a more structured output, which may be beneficial in some administrative tasks.

List Services Cmd: Mastering Service Commands Effortlessly

List Services Cmd: Mastering Service Commands Effortlessly

Advanced User Listing Techniques

Filtering Users with PowerShell (Optional)

Though the focus here is on CMD, mentioning how PowerShell can be utilized for listing users might pique the interest of those exploring more robust solutions.

Get-LocalUser

PowerShell offers enhanced functionalities, such as easy filtering and more extensive data manipulation, making it a valuable tool for those who need more from their user management practices.

System and Hidden Users

To view all users—regardless of their status—the `net localgroup` command can be instrumental. This command not only lists local accounts, but it also reveals system accounts that may not appear in standard queries.

net localgroup

Understanding how to recognize and differentiate between standard and hidden accounts is crucial for maintaining security and performance.

Mastering User in Cmd: A Simple Guide

Mastering User in Cmd: A Simple Guide

Common Issues and Troubleshooting

Permissions Problems

When trying to execute user listing commands, you may encounter permission issues. If CMD does not have sufficient privileges, the commands might fail to display the necessary information. To overcome this, run CMD as an Administrator.

  1. Right-click on the CMD icon.
  2. Select «Run as administrator».

This action will enable elevated permissions, allowing you to execute user listing commands without restrictions.

Error Messages

Some common errors that might pop up when listing users include access denied errors or unrecognized commands. A quick check for typos or reviewing your command syntax can often resolve these problems. Additionally, confirming your CMD version and privileges will ensure smooth operation.

Change User in Cmd: Quick Steps for Fast Switching

Change User in Cmd: Quick Steps for Fast Switching

Practical Use Cases for Listing Users in CMD

System Administration

Being able to list users in CMD is paramount for any systems administrator managing a network or local system. It enables tracking of access permissions and identifying accounts that haven’t been used in some time, which can be critical for maintaining security.

Troubleshooting User Issues

User-related issues can range from incorrect logins to permission errors. Using CMD to quickly list all users can provide insights to assist in diagnosing these problems more effectively.

Check Your Bios Version Using Cmd: A Quick Guide

Check Your Bios Version Using Cmd: A Quick Guide

Conclusion

Understanding how to list users in CMD provides a foundation for effective user management in Windows systems. From basic commands to advanced techniques, CMD offers dynamic methods for monitoring and troubleshooting user accounts. Experimenting with these commands not only strengthens your command-line skills but also enhances your capability to manage system permissions effectively.

Add User in Cmd Windows 10: A Simple Guide

Add User in Cmd Windows 10: A Simple Guide

Resources for Further Learning

Additional CMD Commands to Explore

As you develop your CMD skills, consider exploring related commands such as `net localgroup`, `whoami`, and more. This helps expand your repertoire and improves your efficiency in user and system management.

Community Forums and Support

Engaging with online communities can provide additional insights and troubleshooting tips. Platforms such as Stack Overflow or Windows forums are excellent places to ask questions and share knowledge with fellow CMD users.

The command Net User allows you to manage your local and even your domain users from the command line. It’s mainly used to quickly add, delete or disable user accounts from the command line. But it can do more than just that. The tool can be used in both command prompt and PowerShell.

For managing domain users, I recommend using the PowerShell ActiveDirectory module. It comes with more options and allows you to filter, copy and search users and set or change all properties. But as mentioned, you can also perform basic tasks with the Net User command for domain users.

In this article

In this article, we are going to take a closer look at the Net User command. I will explain how you can add, and remove accounts, change passwords, and more.

The Net User command is a command-line utility that you can run in any terminal on Windows. But to use it you will need to have Administrator permissions on the computer. Without it, you won’t be able to create new user accounts for example. Also, make sure that you open Windows PowerShell or Windows Terminal in Admin mode.

Note

If you get the error “System error 5 has occurred. Access is denied” Then you haven’t start the command prompt or PowerShell with administrator privileges.

The most important parameters of the Net User command are:

Parameter Description
<username> Specify the username to the account you want to perform the action on
<password> Set or change the password for the specified user account. Use * to get a prompt for the password.
/domain Used for managing domain accounts
/add Create a new user account
/delete Delete a user account
/active Enable or disable the user account. Options are yes or no.
/expire Set the date when the account expires
/time Specifies the times that a user is allowed to log in
/homedir Set the home directory path of the user account.
Net User Commands

List all users

When you enter the command Net User without any parameters, then it will list all user accounts on the computer. If you run the command on the Domain Controller, then it will list all domain accounts.

Net User

# Or you can also type
Net Users

In the first screenshot above you will see the results on a local computer, the second one are all the users from the local domain.

When you specify the username you will see all the details from the user account

# Get the user details for Zoe Tucker
net user ztucker

Net User Details

Net User Add Account

The Net User command can be used to create new user accounts on your computer and in your domain. To create a user account you will need to add the /add parameter and specify the username. A password is by default not required on a local computer. For domain accounts, however, you will need to specify the password as well.

# Create a new local user account with the login name lazyadmin
Net User /Add lazyadmin

For entering the password you have two options, you can type it in plain text in the command line or use the * which will show you a prompt to enter the password.

# Create a new domain user with username testusr and passswd123
Net User /add /domain testusr passwd123

# Prompt for the password
Net User /add /domain testusr *
Net User Add

Net User Add

The new domain user is placed in the built-in OU “Users”.

When creating a user we can also specify login details, home directory path, etc of the user. I will explain each command later in the article. But to give you an idea of the possible options, we are going to create a user with the following details:

  • Username: testusr
  • Password: prompt
  • Full name: Test User
  • Password required: yes
  • Allowed to login between: Monday to Friday between 08:00 and 17:00
  • Home folder directory: \\lazyadmin.local\home\testusr
  • Script path: \\lazyadmin.local\netlogon\welcome.bat
Net User /add /domain testusr * /fullname:"Test User" /passwordreq:yes /time:M-F,08:00-17:00 /homedir:"\\lazyadmin.local\home\testusr" /scriptpath:"\\lazyadmin.local\netlogon\welcome.bat"

Net User Delete User Account

We can also use the command line tool to delete user accounts, both local and from the domain. For this, you will need to use the parameter /delete and enter the username. Important to note is that the command tool won’t ask for confirmation. So be careful when using the delete option.

# Delete the local user Lazyadmin
Net User /delete lazyadmin

# Delete a domain user
Net User /delete /domain testusr

Net User Change or Set Password

One of the common tasks for an IT Helpdesk is to reset a user’s password. Of course, you can reset the password in the Active Directory. But it’s also possible with the command Net User. Resetting passwords is not limited to domain accounts, you can also use this method for local computer accounts.

To reset a password you will need to specify the username and then either type in the password or type * after which you can securely type the password:

# Set the password for LazyAdmin to passwd123
Net User LazyAdmin passwd123

# Pormpt for the new password
Net User LazyAdmin *

When it’s a domain user, then just add the /domain parameter. Make sure that the password meets the complexity requirements of the domain

# Reset the password for the domain user tesusr
Net User /domain testusr *

Enable or Disable User accounts

We can also use the command-line tool to enable and disable accounts. This is particularly useful when a user is locked out or when you quickly need to disable an account. To do this we are going to use the parameter /Active:yes|no

The command can be used for local computer accounts as for domain accounts:

# Disable local account
Net User lazyadmin /active:no

# Disable domain user account
Net User tesusr /Domain /Active:no

To enable an account, simply replace /Active:no with /Active:yes

Set Expire date for User Account

If you know the data that an employee leaves the organization then it’s a good idea to set the expired date for the account. This way the account is automatically locked after the specified data. The date format depends on your region settings, but the options are:

  • MM/DD/YYYY
  • DD/MM/YYYY
  • mmm,dd,YYYY

Account expiration settings are not limited to a domain account, you can also set the expired date on a local Windows 10 or 11 user account.

# Set expire date for local user
Net User lazyadmin /expires:21/09/2022

# Set expire data for domain user
Net User testusr /domain /expires:09/20/2022

Set login times for User Account

Some accounts are only allowed to be used between specific hours, office hours for example. We can specify these hours with the /time parameter. To specify the time we will need to enter the days and hours between the account is allowed to log in.

You can use different notions for the days and hours (12-hour or 24-hour notation), and we can specify multiple time blocks by separating them with the semi-column ;.

# Allow login during office hours only
Net User lazyadmin /time:M-F,08:00-17:00

# Or in 12-hour notation
Net User lazyadmin /time:M-F,8am-5pm

# Specify multiple blocks
Net User lazyadmin /time:M,08:00-17:00;W,08:00-13:00;F,08:00-17:00

Net User Password settings

When you create a new account you can set a password for the account as well. But when it comes to passwords we have two other interesting parameters, passwordchg and passwordreg. The first determines if the user can change the password. This setting is really useful for kiosk accounts. The user can’t change the password when this is set to no.

# User lazyadmin can't change it's password
net user lazyadmin /passwordchg:no

The parameter passwordreg is used to specify it a user account must have a password. If this is set to no, then the user can remove their password, making the device vulnerable.

net user lazyadmin /passwordreg:yes

Home Directory Path

The last parameter that I want to mention is the home directory path. If you want to store the home directory of the user on a network share then you can set the path to the folder with the parameter /homedir. But make sure that the full path, including the user’s folder, exists.

# Set the home directory for testusr
net user testusr homedir:"\\lazyadmin.local\home\testusr"

Wrapping Up

The Net User command is great when wanting to quickly enable or disable a user account or reset a password. Also, it’s great to manage local computer accounts on small networks. When working with domain accounts I prefer to use the Active Directory module in PowerShell.

I hope you found this article useful, if you have any questions, just drop a comment below.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Как использовать smb2 в windows 10
  • Windows xp sata driver torrent
  • Браузер для старого ноутбука на windows 7
  • Пропал блютуз на ноутбуке asus windows 10
  • Affinity designer for windows