asktechsupport / help

help@asktechsupport
5 stars 0 forks source link

ServerBuild Buddy Script #67

Closed asktechsupport closed 3 months ago

asktechsupport commented 3 months ago

MVP1

Set-NetIPInterface -InterfaceAlias Ethernet0 #set to match the default interface alias value Get-NetIPConfiguration $ip = Read-Host "Enter the IP address" New-NetIPAddress -IPAddress $ip -PrefixLength 24 -DefaultGateway "10.0.0.1" -InterfaceIndex $getinterfaceindex Set-DnsClientServerAddress -InterfaceIndex $getinterfaceindex -ServerAddresses ("10.0.0.10","10.0.0.11")

Set Suffixes - credit https://eddiejackson.net/lab/2022/03/08/powershell-add-dns-suffix-to-ethernet-connections/

Set-DnsClientGlobalSetting -SuffixSearchList @("domain.com", "test.domain.com","uat.domain.com")

Rename and join domain - credit https://stackoverflow.com/a/13492388

get the credential

$cred = get-credential

Add and rename the computer with a prompt

Add-Computer -DomainName "domain.com" -Credential $cred -NewName (Read-Host -Prompt "Input the new PC name") Get-NetIPConfiguration

refresh dns

ipconfig /registerdns

asktechsupport commented 3 months ago

PowerShell Script v1

#Disable ipv6
reg add hklm\system\currentcontrolset\services\tcpip6\parameters /v DisabledComponents /t REG_DWORD /d 0xFF /f
Get-NetAdapterBinding –ComponentID “ms_tcpip6” | disable-NetAdapterBinding –ComponentID “ms_tcpip6” –PassThru

Set-NetIPInterface -InterfaceAlias 'Ethernet0' #set to match the default interface alias value
Get-NetIPConfiguration
$ip = Read-Host "Enter the IP address"
Set-NetIPAddress -InterfaceAlias 'Ethernet0' -IPAddress $ip -PrefixLength 24
Set-DnsClientServerAddress -InterfaceIndex 14 -ServerAddresses ("enter your DNS","enter your dns")

#Set Suffixes - credit https://eddiejackson.net/lab/2022/03/08/powershell-add-dns-suffix-to-ethernet-connections/
Set-DnsClientGlobalSetting -SuffixSearchList @(“domain.com”, “test.domain.com”,“uat.domain.com”)

#Rename and join domain - credit https://stackoverflow.com/a/13492388
# get the credential 
$cred = get-credential

# enter the computer in the right place
Add-Computer -DomainName YOURDOMAINNAME -Credential $cred

# rename the computer with credential (because we are in the domain)
$Computer = Get-WmiObject Win32_ComputerSystem
$r = $Computer.Rename("NewComputerName", $cred.GetNetworkCredential().Password, $cred.Username)
asktechsupport commented 3 months ago

Sysadmin Buddy Script V2

#Disable ipv6
Get-NetAdapterBinding –ComponentID ms_tcpip6 | disable-NetAdapterBinding -ComponentID ms_tcpip6 -PassThru
$getinterfaceindex = Get-NetIPConfiguration | select -ExpandProperty InterfaceIndex

Set-NetIPInterface -InterfaceAlias Ethernet0 #set to match the default interface alias value
Get-NetIPConfiguration
$ip = Read-Host "Enter the IP address"
Set-NetIPAddress -IPAddress $ip -PrefixLength 24 -InterfaceIndex $getinterfaceindex 
Set-DnsClientServerAddress -InterfaceIndex $getinterfaceindex -ServerAddresses ("10.0.0.10","10.0.0.11")

#Set Suffixes - credit https://eddiejackson.net/lab/2022/03/08/powershell-add-dns-suffix-to-ethernet-connections/
Set-DnsClientGlobalSetting -SuffixSearchList @("domain.com", "test.domain.com","uat.domain.com")

#Rename and join domain - credit https://stackoverflow.com/a/13492388
# get the credential 
$cred = get-credential

# Add and rename the computer with a prompt
Add-Computer -DomainName "domain.com" -Credential $cred -NewName (Read-Host -Prompt "Input the new PC name")
Get-NetIPConfiguration
asktechsupport commented 3 months ago

V3

Notes

#Disable ipv6
Get-NetAdapterBinding –ComponentID ms_tcpip6 | disable-NetAdapterBinding -ComponentID ms_tcpip6 -PassThru
$getinterfaceindex = Get-NetIPConfiguration | select -ExpandProperty InterfaceIndex

Set-NetIPInterface -InterfaceAlias Ethernet0 #set to match the default interface alias value
Get-NetIPConfiguration
$ip = Read-Host "Enter the IP address"
New-NetIPAddress -IPAddress $ip -PrefixLength 24 -DefaultGateway "10.0.0.1" -InterfaceIndex $getinterfaceindex 
Set-DnsClientServerAddress -InterfaceIndex $getinterfaceindex -ServerAddresses ("10.0.0.10","10.0.0.11")

#Set Suffixes - credit https://eddiejackson.net/lab/2022/03/08/powershell-add-dns-suffix-to-ethernet-connections/
Set-DnsClientGlobalSetting -SuffixSearchList @("domain.com", "test.domain.com","uat.domain.com")

#Rename and join domain - credit https://stackoverflow.com/a/13492388
# get the credential 
$cred = get-credential

# Add and rename the computer with a prompt
Add-Computer -DomainName "domain.com" -Credential $cred -NewName (Read-Host -Prompt "Input the new PC name")
Get-NetIPConfiguration

#refresh dns

ipconfig /registerdns