<#

文件:domain.ps1

用途:用于加域功能脚本

#>


#修改计算机名

Rename-Computer -NewName hz


#添加DNS

Get-DnsClientServerAddress -AddressFamily IPv4 |Out-GridView -PassThru |foreach { Set-DnsClientServerAddress -InterfaceIndex $_.InterfaceIndex -Addresses '192.168.3.200'}

ifconfig /flushdns


#加域

$domain = "company" 

$password = ConvertTo-SecureString "qwe123!@#" -AsPlainText -Force

$username = "$domain\ad" 

$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password

Add-Computer -DomainName $domain -Credential $credential


#重启电脑

Restart-Computer