Posts

Showing posts from July, 2020

Powershell script - Rename computer and join domain

I had to automate the process. I used the following script: $hostname = read-host 'hostname' $Domain = 'domain.com' $Credential = Get-Credential Rename-Computer $hostname Add-Computer -Domain $Domain -NewName $hostname -Credential $Credential -Restart -Force if you also need to setup ip: $ipaddress = read-host 'enter new ip' $gateway = read-host 'gateway:' $prefix = read-host 'prefix (ie 24):' $dns1 = read-host 'dns 1' $dns2 = read-host 'dns 2' New-NetIPAddress –IPAddress $ipaddress -DefaultGateway $gateway -PrefixLength $prefix -InterfaceIndex (Get-NetAdapter).InterfaceIndex Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter).InterfaceIndex -ServerAddresses ($dns1, $dns2) $hostname = read-host 'hostname' $Domain = read-host 'domain' $Credential = Get-Credential Rename-Computer $hostname Add-Computer -Domain $Domain -NewName $hostname -Credential $Credential -Restart -Force

Popular posts from this blog

[SOLVED] Veeam: Failed change tracking (CBT)