Windows Server 2022 中使用 PowerShell 5.1 进行域管理时,您可以使用一些命令来执行各种操作。以下是一些 命令:
-
创建新用户:
powershellCopy CodeNew-ADUser -Name "John Doe" -SamAccountName "johndoe" -AccountPassword (ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force) -Enabled $true -Path "OU=Users,DC=example,DC=com"
-
创建新组:
powershellCopy CodeNew-ADGroup -Name "IT Group" -GroupScope Global -Path "OU=Groups,DC=example,DC=com"
-
查找特定用户:
powershellCopy CodeGet-ADUser -Identity "johndoe"
-
查找特定组的成员:
powershellCopy CodeGet-ADGroupMember -Identity "IT Group"
-
重置用户密码:
powershellCopy CodeSet-ADAccountPassword -Identity "johndoe" -NewPassword (ConvertTo-SecureString "NewP@ssw0rd" -AsPlainText -Force)
-
移动用户到指定组织单位:
powershellCopy CodeMove-ADObject -Identity "CN=John Doe,OU=Users,DC=example,DC=com" -TargetPath "OU=NewUsers,DC=example,DC=com"
-
禁用用户账户:
powershellCopy CodeDisable-ADAccount -Identity "johndoe"
-
启用用户账户:
powershellCopy CodeEnable-ADAccount -Identity "johndoe"
-
删除用户账户:
powershellCopy CodeRemove-ADUser -Identity "johndoe" -Confirm:$false
-
查找特定计算机对象:
powershellCopy CodeGet-ADComputer -Filter {Name -like "Computer*"}
-
查找特定组的属性:
powershellCopy CodeGet-ADGroup -Identity "IT Group"
-
向组添加成员:
powershellCopy CodeAdd-ADGroupMember -Identity "IT Group" -Members "johndoe", "janedoe"
-
从组中移除成员:
powershellCopy CodeRemove-ADGroupMember -Identity "IT Group" -Members "janedoe"
-
设置用户账户属性:
powershellCopy CodeSet-ADUser -Identity "johndoe" -EmailAddress "[email protected]"
-
列出所有域控制器:
powershellCopy CodeGet-ADDomainController -Filter *