当前位置:网站首页>PowerShell plus domain add computer module

PowerShell plus domain add computer module

2022-06-13 04:36:00 A boy looking forward to the future

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/add-computer?view=powershell-5.1
Add the local computer to a domain or workgroup .

grammar
PowerShell

Copy

Add-Computer
   [-ComputerName <String[]>]
   [-LocalCredential <PSCredential>]
   [-UnjoinDomainCredential <PSCredential>]
   -Credential <PSCredential>
   [-DomainName] <String>
   [-OUPath <String>]
   [-Server <String>]
   [-Unsecure]
   [-Options <JoinOptions>]
   [-Restart]
   [-PassThru]
   [-NewName <String>]
   [-Force]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-Computer
   [-ComputerName <String[]>]
   [-LocalCredential <PSCredential>]
   [-Credential <PSCredential>]
   [-WorkgroupName] <String>
   [-Restart]
   [-PassThru]
   [-NewName <String>]
   [-Force]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

describe
The cmdlet Add a local or remote computer to a domain or workgroup , Or move them from one domain to another . If you add a computer to a domain without an account , It also creates a domain account .Add-Computer You can use this cmdlet The parameter of specifies the organizational unit (OU) And domain controllers , Or perform an unsafe connection . To get the results of a command , Please use “ detailed ” and “ Pass on ” Parameters .

Case study

# Domain information 
$domain = "abc.com" 
$User =  "ADusername" 
$Password = "ADpassword" | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($User,$Password)

# With new pc Name join to domain 
Add-Computer  -DomainName $domain -Confirm:$false -Credential $credential  

# Restart the computer 
Restart-Computer

result
 Insert picture description here

原网站

版权声明
本文为[A boy looking forward to the future]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130429191007.html