Skip to content

Instantly share code, notes, and snippets.

@vinyar
Last active August 29, 2015 14:15
Show Gist options
  • Save vinyar/22f45f20327a7eba8403 to your computer and use it in GitHub Desktop.
Save vinyar/22f45f20327a7eba8403 to your computer and use it in GitHub Desktop.
Configuring DNS and WINS for Win2k8r2 NIC to allow domain joining
Import-Module ActiveDirectory
$ou = (Get-ADOrganizationalUnit -Filter 'New Members').DistinguishedName
redircmp $ou
redirusr $ou
Add-Computer -domainname DOMAIN -OUPath "OU=OU1,OU=OU2,OU=Domainname,DC=company,DC=com" -cred DOMAIN\AuthorizedUser -passthru –verbose
powershell_script 'configure WINS on NIC_1' do
code <<-BLOCK
$Nic = Get-WMIObject Win32_NetworkAdapter |where{$_.NetConnectionID -eq "Local Area Connection"}
$Config = Get-WMIObject Win32_NetworkAdapterConfiguration |where{$_.MACAddress -eq $Nic.MACAddress}
$pri = $config.winsprimaryserver
$sec = $config.winsSecondaryServer
$config.SetWinsServer("#{node['ad_wrapper']['primary_wins']}","#{node['ad_wrapper']['secondary_wins']}")
$Config.SetDNSServerSearchOrder("#{node['ad_wrapper']['primary_wins']}")
BLOCK
end
# any more nics and im making it a loop
powershell_script 'configure WINS on NIC_2' do
code <<-BLOCK
$Nic = Get-WMIObject Win32_NetworkAdapter |where{$_.NetConnectionID -eq "Local Area Connection 2"}
$Config = Get-WMIObject Win32_NetworkAdapterConfiguration |where{$_.MACAddress -eq $Nic.MACAddress}
$pri = $config.winsprimaryserver
$sec = $config.winsSecondaryServer
$config.SetWinsServer("#{node['ad_wrapper']['primary_wins']}","#{node['ad_wrapper']['secondary_wins']}")
$Config.SetDNSServerSearchOrder("#{node['ad_wrapper']['primary_wins']}")
BLOCK
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment