Windows Server 2022 初始设置

一、添加本地用户

添加新的本地用户。

在CUI配置上,按如下方式设置。

  • 使用管理员权限运行 PowerShell 并按如下方式进行配置。
Windows PowerShell
版权所由 (C) Microsoft Corporation。 保留所有权利。
安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows
# 例如,添加 [NC086] 用户
# [P@ssw0rd01] ⇒您设置的密码(根据需要替换)
# [PasswordNeverExpires] ⇒设置密码永不过期(如果设置默认过期,则不指定此选项)
PS C:\Users\Administrator> New-LocalUser -Name "NC086" `
-FullName "NC086" `
-Description "此计算机的管理员" `
-Password (ConvertTo-SecureString -AsPlainText "P@ssw0rd01" -Force) `
-PasswordNeverExpires `
-AccountNeverExpires 
Name Enabled Description
---- ------- -----------
NC086 True 此计算机的管理员
# 如果向用户授予权限,请将其添加到 [管理员] 组
PS C:\Users\Administrator> Add-LocalGroupMember -Group "Administrators" -Member "NC086" 
# 验证
PS C:\Users\Administrator> Get-LocalUser -Name NC086 
Name Enabled Description
---- ------- -----------
NC086 True 此计算机的管理员
PS C:\Users\Administrator> Get-LocalGroupMember -Group "Administrators" 
ObjectClass Name PrincipalSource
----------- ---- ---------------
User WIN-PA24S3GQ6G3\Administrator Local
User WIN-PA24S3GQ6G3\NC086 Local
# 如果删除用户,请执行如下操作
PS C:\Users\Administrator> Remove-LocalUser -Name "NC086"

 

在GUI配置上,按如下方式设置。

  • 运行【服务器管理器】并打开【工具】【计算机管理】。

  • 右键单击左侧窗格中【本地用户和组】下的【用户】,然后选择【新建用户】。

  • 输入新用户的用户名和密码后,点击【创建】按钮。其他 intems 是可选设置的。

  • 创建成功后,新用户将显示在列表中,如下所示。

  • 如果要为新用户设置管理权限,请右键单击该用户并打开【属性】。

  • 移至【成员】选项卡,然后单击【添加】按钮。

  • 指定【管理员】组,如下所示。

  • 确保列表中添加了【管理员】组,然后单击【确定】按钮完成设置。

  • 在【Administrators】组属性中,用户已添加。

 

 

二、更改管理员用户名

如果出于某些原因(如安全性)想要更改管理员账户名称,可以进行如下更改。

在CUI配置上,按如下方式设置。

Windows PowerShell
版权所由 (C) Microsoft Corporation。 保留所有权利。
安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows
# 例如,将名称 [Administrator] 更改为 [NC086Admin]
PS C:\Users\Administrator> Rename-LocalUser -Name "Administrator" -NewName "NC086Admin" 
PS C:\Users\Administrator> Get-LocalUser 
# changed
Name Enabled Description
---- ------- -----------
DefaultAccount False A user account managed by the system.
Guest False Built-in account for guest access to the computer/domain
NC086 True 此计算机的管理员
NC086Admin True Built-in account for administering the computer/domain
WDAGUtilityAccount False A user account managed and used by the system for Windows Defender Application Guard scenarios.

 

在GUI配置上,按如下方式设置。

  • 运行【服务器管理器】并打开【工具】【计算机管理】。

  • 在左窗格中打开【本地用户和组】【用户】,然后右键单击【管理员】,然后在右窗格中选择【重命名】。然后,更改您喜欢的任何名称。

  • 管理员名称刚刚更改。

 

 

三、设置计算机名称

默认情况下,计算机名称是自动分配的,因此请更改它。

在CUI配置上,按如下方式设置。

  • 使用管理员权限运行 PowerShell 并按如下方式进行配置。
Windows PowerShell
版权所由 (C) Microsoft Corporation。 保留所有权利。
安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows
# 例如,将“计算机名称”更改为 [NC086]
PS C:\Users\Administrator> Rename-Computer -NewName NC086 -Force -PassThru 
HasSucceeded OldComputerName NewComputerName
------------ --------------- ---------------
True WIN-VIMPQCFFRBH NC086
WARNING: The changes will take effect after you restart the computer WIN-VIMPQCFFRBH.
# 例如,将主 DNS 后缀更改为 [ncncet.com]
PS C:\Users\Administrator> Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" –Name "NV Domain" –Value "ncncet.com" -PassThru 
NV Domain : ncncet.com
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip
PSChildName : Parameters
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
# 重新启动计算机以应用更改
PS C:\Users\Administrator> Restart-Computer -Force 
# 验证
PS C:\Users\Administrator> (ipconfig /all)[0..9] 
Windows IP Configuration
 Host Name . . . . . . . . . . . . : NC086
 Primary Dns Suffix . . . . . . . : ncncet.com
 Node Type . . . . . . . . . . . . : Hybrid
 IP Routing Enabled. . . . . . . . : No
 WINS Proxy Enabled. . . . . . . . : No
 DNS Suffix Search List. . . . . . : ncncet.com

 

在GUI配置上,按如下方式设置。

  • 运行【服务器管理器】,在左侧窗格中选择【本地服务器】,然后单击右键窗格中的【计算机名称】部分。

  • 移至【计算机名称】选项卡,然后单击【更改】按钮。

  • 在【计算机名称】字段中输入您喜欢的任何计算机名称,然后单击【更多...】按钮。(:彩蛋

  • 输入此计算机所在的域名。

  • 应用更改需要重新启动计算机。

  • 计算机名称已成功更改。

 

 

四、设置静态IP地址

默认情况下,IP地址由DHCP分配,因此请为服务器使用设置静态IP地址。此示例显示仅设置IPv4地址。

在CUI配置上,按如下方式设置。

  • 使用管理员权限运行 PowerShell 并按如下方式进行配置。
Windows PowerShell
版权所由 (C) Microsoft Corporation。 保留所有权利。
安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows
# display network interfaces
PS C:\Users\Administrator> Get-NetIPInterface -AddressFamily IPv4 
ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore
------- -------------- ------------- ------------ --------------- ---- --------------- -----------
11 Ethernet0 IPv4 1500 25 Enabled Connected ActiveStore
1 Loopback Pseudo-Interface 1 IPv4 4294967295 75 Disabled Connected ActiveStore
# set DHCP off(将 InterfaceIndex 编号替换为您自己的环境(上面的 ifIndex))
PS C:\Users\Administrator> Set-NetIPInterface -InterfaceIndex 6 -Dhcp Disabled 
# 例如,设置 IP 地址 [192.168.200.101/24], gateway [192.168.200.1]
PS C:\Users\Administrator> New-NetIPAddress -InterfaceIndex 11 -AddressFamily IPv4 -IPAddress "192.168.200.101" -PrefixLength 24 -DefaultGateway "192.168.200.1" 
IPAddress : 192.168.200.101
InterfaceIndex : 11
InterfaceAlias : Ethernet0
AddressFamily : IPv4
Type : Unicast
PrefixLength : 24
PrefixOrigin : Manual
SuffixOrigin : Manual
AddressState : Preferred
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : False
PolicyStore : ActiveStore
# 例如,设置 DNS [192.168.200.1]
PS C:\Users\Administrator> Set-DnsClientServerAddress -InterfaceIndex 11 -ServerAddresses "192.168.200.101" -PassThru 
InterfaceAlias Interface Address ServerAddresses
 Index Family
-------------- --------- ------- ---------------
Ethernet0 11 IPv4 {192.168.200.101}
Ethernet0 11 IPv6 {}
# 确认设置
PS C:\Users\Administrator> ipconfig /all 
Windows IP Configuration
 Host Name . . . . . . . . . . . . : NC086
 Primary Dns Suffix . . . . . . . : ncncet.com
 Node Type . . . . . . . . . . . . : Hybrid
 IP Routing Enabled. . . . . . . . : No
 WINS Proxy Enabled. . . . . . . . : No
 DNS Suffix Search List. . . . . . : ncncet.com
Ethernet adapter Ethernet0:
 Connection-specific DNS Suffix . :
 Description . . . . . . . . . . . : Intel(R) 82574L Gigabit Network Connection
 Physical Address. . . . . . . . . : 00-0C-29-D9-45-D3
 DHCP Enabled. . . . . . . . . . . : No
 Autoconfiguration Enabled . . . . : Yes
 Link-local IPv6 Address . . . . . : fe80::74:ecfd:e898:b756%7(Preferred)
 IPv4 Address. . . . . . . . . . . : 192.168.200.101(Preferred)
 Subnet Mask . . . . . . . . . . . : 255.255.255.0
 Default Gateway . . . . . . . . . : 192.168.200.1
 DHCPv6 IAID . . . . . . . . . . . : 100666409
 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-2D-E2-30-C2-00-0C-29-D9-45-D3
 DNS Servers . . . . . . . . . . . : 192.168.200.1
 NetBIOS over Tcpip. . . . . . . . : Enabled

 

在GUI配置上,按如下方式设置。

  • 运行【服务器管理器】,在左侧窗格中选择【本地服务器】,然后单击右侧窗格中的【以太网】部分。

  • 双击【以太网】图标。

  • 点击【属性】按钮。

  • 选择【互联网协议版本4】,然后单击【属性】按钮。

  • 为本地网络设置静态IP地址和网关等。

  • 设置静态IP地址后,将在服务器上启用更改。(:彩蛋

 

 

五、Windows 更新

配置 Windows 更新。

  • 右键单击窗口开始图标,然后打开【运行】。

  • 输入【gpedit.msc】和【OK】。

  • 在左窗格中选择【计算机配置】【管理模板】【Windows组件】【Windows更新】,然后单击【配置自动更新】在右窗格中打开。

  • 配置所需的 Windows 更新设置。

 

 

六、允许ICMP回显回复

Windows 防火墙的默认设置会阻止ICMP,因此服务器永远不会使用ping命令从其他主机进行回复。如果要允许ICMP,请按如下方式设置。

在CUI配置上,按如下方式设置。

  • 使用管理员权限运行 PowerShell 并按如下方式进行配置。
Windows PowerShell
版权所由 (C) Microsoft Corporation。 保留所有权利。
安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows
# 允许 ICMPv4
PS C:\Users\Administrator> New-NetFirewallRule `
-Name 'ICMPv4' `
-DisplayName 'ICMPv4' `
-Description 'Allow ICMPv4' `
-Profile Any `
-Direction Inbound `
-Action Allow `
-Protocol ICMPv4 `
-Program Any `
-LocalAddress Any `
-RemoteAddress Any 
# 确认设置
PS C:\Users\Administrator> Get-NetFirewallRule | Where-Object Name -Like 'ICMPv4' 
Name : ICMPv4
DisplayName : ICMPv4
Description : Allow ICMPv4
DisplayGroup :
Group :
Enabled : True
Profile : Any
Platform : {}
Direction : Inbound
Action : Allow
EdgeTraversalPolicy : Block
LooseSourceMapping : False
LocalOnlyMapping : False
Owner :
PrimaryStatus : OK
Status : The rule was parsed successfully from the store. (65536)
EnforcementStatus : NotApplicable
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local
RemoteDynamicKeywordAddresses : {}

 

在GUI配置上,按如下方式设置。

  • 运行【服务器管理器】并打开【工具】【高级安全Windows Defender防火墙】。

  • 在左侧窗格中选择【入站规则】,然后单击右键窗格中的【新建规则】。

  • 选择【自定义】。

  • 选择【所有程序】。

  • 在【协议类型】上选择【ICMPv4】。

  • 指定允许ICMP的网络范围。

  • 选择【允许连接】。

  • 选择要允许ICMP的网络配置文件。

  • 在【Nmae】字段中输入任何名称。没关系,您的服务器将回复来自其他主机的ping命令。

  • 没关系,您的 Windows 服务器会回复来自其他计算机的ICMP请求。

(:彩蛋,也有可能是缺你一个评论或点赞哦 

 

作者:筱崋原文地址:https://www.cnblogs.com/nc086/p/18211592

%s 个评论

要回复文章请先登录注册