-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathChangeDNS-WINS-NJ.ps1
More file actions
30 lines (23 loc) · 1.25 KB
/
ChangeDNS-WINS-NJ.ps1
File metadata and controls
30 lines (23 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Paste the script below into a PowerShell prompt
get-content c:\computernamesnj.txt | foreach {
$Server = $_
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $Server -filter "IpEnabled=True"
Foreach ($NIC in $NICs) {
if ($NIC.DNSServerSearchOrder -ne $null) {
#Gets the individual NIC adapter name based on the index number of the NIC
$Adapter = Get-WMIObject Win32_NetworkAdapter -computername $Server | where {$_.index -eq $NIC.index}
write-host "name " $Adapter.NetConnectionID
#we need to convert this to a normal variable so that we can use it nicely later
$interface = $Adapter.NetConnectionID
#sets wins based on the NIC name
#compiles scriptblocks first to allow us to add a varible into the command
$sb1 = [scriptblock]::create('psexec \\$Server netsh interface ip add wins $Interface 10.4.72.40 index=1')
$sb2 = [scriptblock]::create('psexec \\$Server netsh interface ip add wins $Interface 10.4.72.41 index=2')
$sb3 = [scriptblock]::create('psexec \\$Server netsh interface ip add wins $Interface 10.0.0.1 index=3')
#invokes the compiled commadn on the remote server
Invoke-Command -ScriptBlock $sb1
Invoke-Command -ScriptBlock $sb2
Invoke-Command -ScriptBlock $sb3
}
}
}