Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServerBuild Buddy Script #67

Closed
1 task done
asktechsupport opened this issue Aug 3, 2024 · 3 comments
Closed
1 task done

ServerBuild Buddy Script #67

asktechsupport opened this issue Aug 3, 2024 · 3 comments
Assignees

Comments

@asktechsupport
Copy link
Owner

asktechsupport commented Aug 3, 2024

MVP1

@asktechsupport
Copy link
Owner Author

asktechsupport commented Aug 3, 2024

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 asktechsupport changed the title Syadmin Buddy Script Sysadmin Buddy Script Aug 3, 2024
@asktechsupport
Copy link
Owner Author

asktechsupport commented Aug 3, 2024

Sysadmin Buddy Script V2

  • bug - Default Gateway does not get set
#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
Copy link
Owner Author

asktechsupport commented Aug 3, 2024

V3

Notes

  • V3 fixes an issue where the Default Gateway was not getting set
  • V3 initiates a dns registration after all is done
  • Restart manually
  • (DISCLAIMER) time taken to perform the DNS updates may vary on slower or more mature environments. As we all know, you can build a set of servers in many many different ways, many of them not aligning with best practices due to delivery constraints.
#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

@asktechsupport asktechsupport self-assigned this Aug 3, 2024
@asktechsupport asktechsupport changed the title Sysadmin Buddy Script ServerBuild Buddy Script Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant