Associate
- Joined
- 28 Oct 2002
- Posts
- 1,819
- Location
- SE London
For the past hour I've been going slightly insane with this script, basically I wrote it to do a server by input, but now I want it to do it by reading a text file and then each line in there does something... I've had this working before, but C&P'ing the line from the older script that did something (just the foreach bit) else seemingly doesn't work here, here is what I've got:
Here is what I get as an error:
Any help will be most appriciated!
Code:
foreach ($Servername in Get-Content h:\moopit.txt )
$NICs = Get-WMIObject -computer $Servername Win32_NetworkAdapterConfiguration | where{$_.IPEnabled -eq “TRUE"}
Foreach($NIC in $NICs) {
psexec \\"$Servername" netsh -c interface dump > "$Servername".txt
$DNSServers = “10.1.80.2","10.1.80.238"
$NIC.SetDNSServerSearchOrder($DNSServers)
$NIC.SetDynamicDNSRegistration("TRUE")
$NIC.SetWINSServer("10.1.80.2","10.1.80.238")
psexec \\"$Servername" ipconfig /registerdns
psexec \\"$Servername" ipconfig /flushdns
psexec \\"$Servername" ipconfig /all >> "$Servername".txt
psexec \\"$Servername" nslookup NYDC10 >> "$Servername".txt
type "$Servername.txt"
}
Code:
Missing statement body in foreach loop.
At H:\setdnswins.ps1:3 char:1
+ <<<< $NICs = Get-WMIObject -computer $Servername Win32_NetworkAdapterConfiguration | where{$_.IPEnabled -eq "TRUE"}
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : MissingForeachStatement
Any help will be most appriciated!