Skip to content

Instantly share code, notes, and snippets.

@PCfromDC
Last active November 25, 2015 20:37
Show Gist options
  • Save PCfromDC/7bd190a4c03effd11063 to your computer and use it in GitHub Desktop.
Save PCfromDC/7bd190a4c03effd11063 to your computer and use it in GitHub Desktop.
Ignite 2015 session Using Desired State Configuration to Deploy SQL
$domain = "contoso.local"
$newName ="SQL03"
$OUPath = # to put computer in specific OU
$prefixLength = 24 # PrefixLength of 24 equals a subnet mask of 255.255.255.0
# Update Description
Write-Host -ForegroundColor Green "Updating server description..."
$desc = Get-WmiObject -Class Win32_OperatingSystem
$desc.Description = $newName
$desc.put()
# Update NIC
Write-Host -ForegroundColor Green "Getting NIC information..."
$nicInfo = Get-NetIPAddress -AddressFamily IPv4 -IncludeAllCompartments | Where {$_.InterfaceAlias -ilike "*Ethernet*"}
$nicName = $nicInfo.InterfaceAlias
$netIP = "192.168.5.3"
$netSubnet = "255.255.255.0"
$netGateway = "192.168.5.1"
$netDNSs = "192.168.5.1"
# Updates NIC using netsh
Write-Host -ForegroundColor Green "Updating NIC information..."
# Set IP
netsh interface ip set address name= $nicName static addr=$netIP mask=$netSubnet gateway=$netGateway | Out-Null
netsh interface ip set dns $nicName static $netDNSs | Out-Null
# Join domain
$credential = "contoso\administrator"
Write-Host -ForegroundColor Green "Changing Server Name and Joining Domain..."
Add-Computer -ComputerName $env:COMPUTERNAME -NewName $newName -DN $domain -Credential $credential -Restart # -OUPath $OUPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment