Windows operating system have a lot of command line and GUI tools to manage user accounts. The most popular user management tool from command line like ms-dos or powershell is net user
command. In this tutorial we will look different usage examples about net user command.
Windows操作系统具有许多用于管理用户帐户的命令行和GUI工具。 诸如ms-dos或powershell等命令行中最流行的用户管理工具是net user
命令。 在本教程中,我们将查找有关net user命令的不同用法示例。
帮帮我 (Help)
Help about the net user command can be get with the /?
option like below.
可以使用/?
获得有关net user命令的帮助/?
如下所示的选项。
$ net user /?

区分大小写(Case Sensitivity)
Before starting issuing commands we need to know that Windows is generally incase sensitive system. So following commands can be used uppercase or lowercase with username. The only exception is the password. So following commands are the same. But using accepted usage which is uppercase will make commands more readable
在开始发出命令之前,我们需要知道Windows通常是区分大小写的系统。 因此,以下命令可以与用户名一起使用大写或小写。 唯一的例外是密码。 因此,以下命令相同。 但是使用大写的可接受用法将使命令更具可读性
net user
NeT UsEr
列出用户 (List Users)
Existing user accounts can be listed just issuing the net user
command without any option. Only local user accounts will be listed. Domain user accounts will not be listed.
只需发出net user
命令即可列出现有的用户帐户,而无需任何选择。 仅列出本地用户帐户。 域用户帐户将不会列出。
$ net user

As we can the the default users like Administrator and Guest all ready exist. New user ismail
is added previously.
尽我们所能,默认用户(例如Administrator和Guest)已经准备就绪。 先前已添加新用户ismail
。
获取用户帐户信息 (Get User Account Information)
The user information can be get by providing the user account name.
用户信息可以通过提供用户帐户名获得。
$ net user jack

This will list following information;
这将列出以下信息;
- User name 用户名
- Full name全名
- Comment评论
- User’s comments用户评论
- Country Code国家代码
- Account Active帐户有效
Account Expires
line shows where her after specified time account will be lockedAccount Expires
行显示她在指定时间后将被锁定的位置Password Last Set
line shows when the password is set for the last timePassword Last Set
行显示Password Last Set
密码的时间Password Expires
line shows whether the password of the user will expire after specified time.Password Expires
行显示用户的密码在指定时间后是否将过期。Password Changeable
Password Changeable
Password Required
line shows whether user account login needs password.Password Required
行显示用户帐户登录是否需要密码。User may change password
line show whether the user have privileges to change his own password.User may change password
行,显示用户是否有权更改自己的密码。Workstations allowed
line show in which computers the user can login.Workstations allowed
行显示用户可以登录的计算机。Logon script
line shows which script file will be run during user logonLogon script
行显示在用户登录期间将运行哪个脚本文件User profile
User profile
Home directory
line shows if the user home path is different then default location what is the user home path.Home directory
行显示用户Home directory
路径是否不同,然后默认位置是用户主目录路径。Last logon
line shows what is the time where the user last time login.Last logon
行显示用户上次登录的时间。Logon hours allowed
line shows which hours is the user allowed to login.Logon hours allowed
行显示Logon hours allowed
用户登录的时间。Local Group Memberships
line show the local groups where the user is a memberLocal Group Memberships
行显示用户所在的本地组Global group memberships
line show the global groups where the user is a memberGlobal group memberships
行显示用户所属的全局组
创建用户帐号(Create User Account)
Users can be created with net user
. This user will be created locally and do not exists in Active Directory. We will provide the user name to the command and /ADD
option like below. In this example we create a user named test
.
可以使用net user
创建net user
。 该用户将在本地创建,并且在Active Directory中不存在。 我们将提供用户名给命令和/ADD
选项,如下所示。 在此示例中,我们创建一个名为test
的用户。
$ net user test /ADD

The user is created successfully. If there is a problem we will get an error like
用户创建成功。 如果有问题,我们会收到类似的错误
The account all ready exists
The account all ready exists
System error 5 has occurred. Access is denied
is we have do not have required privileges like Administrator.System error 5 has occurred. Access is denied
System error 5 has occurred. Access is denied
因为我们没有管理员那样的必需特权。
删除用户帐号 (Remove User Account)
A user can be easily removed with the /DELETE
option.
使用/DELETE
选项可以轻松删除用户。
$ net user test /DELETE

创建用户帐户时设置密码(Set Password While User Account Creation)
While creating user account we can set the password. But changing user creation time password will make things more secure. We will just append the user account password after user account name. In this example we will create a user account named test and set password 123456
创建用户帐户时,我们可以设置密码。 但是更改用户创建时间密码将使事情更加安全。 我们将仅在用户帐户名称后附加用户帐户密码。 在此示例中,我们将创建一个名为test的用户帐户并设置密码123456。
$ net user test 123456 /ADD

设置密码现有用户(Set Password Existing User)
Changing existing user password is very similar to while adding. We will just remove the /ADD
and only provide the user account name and new password. In this example we set user test
password as 654321
更改现有用户密码与添加时非常相似。 我们将只删除/ADD
,仅提供用户帐户名和新密码。 在此示例中,我们将用户test
密码设置为654321
$ net user test 123456

在域用户上操作(Operate On Domain Users)
Up to now we have operated on local users. Windows Active directory very popular technology used by corporates. Previously described commands can be used to manipulate domain users too. We just need to add /DOMAIN
option to the command. We need Domain Admin privileges to run these commands. Also current worked computer should be joined related domain.
到目前为止,我们已经对本地用户进行了操作。 Windows Active Directory是企业使用的非常流行的技术。 先前描述的命令也可以用于操纵域用户。 我们只需要在命令中添加/DOMAIN
选项即可。 我们需要Domain Admin特权才能运行这些命令。 当前工作的计算机也应加入相关领域。
将用户帐户添加到域 (Add User Account To Domain)
$ net user test /ADD /DOMAIN
删除删除用户帐户 (Delete Remove User Account)
$ net user test /DELETE /DOMAIN
修改用户帐号密码 (Change User Account Password)
$ net user test 123456 /DOMAIN
锁定或禁用用户帐户 (Lock or Disable User Account)
Windows operating system provides the ability to lock or disable user accounts. Locking accounts generally used for security. Locking or disabling account will prevent the account to login to the Windows systems. User account can be locked or disabled with /active:no
option.
Windows操作系统提供了锁定或禁用用户帐户的功能。 锁定帐户通常用于安全性。 锁定或禁用帐户将阻止该帐户登录Windows系统。 可以使用/active:no
选项锁定或禁用用户帐户。
In this example we will lock user account named jack
.
在此示例中,我们将锁定名为jack
用户帐户。
$ net user jack /active:no
启用用户帐号 (Enable User Account)
The reverse operation can be done to enable all ready locked or disabled account. In this example we will unlock the user account jack
.
可以执行相反的操作来启用所有准备好的锁定或禁用帐户。 在此示例中,我们将解锁用户帐户jack
。
$ net user jack /active:yes
翻译自: https://www.poftut.com/windows-user-management-net-user-like-creating-deleting-setting-password/