If this is the incorrect place to post this question, I appologize in advance and if you could let me know where is a better place to post this question I would greatly apprecicate it.
The end goal here is to write script to change the WINS setting on like a 300 servers. Since there are so many and it will be an production enviroment, I want to include some fail safes. I've written one in Powershell that should work just fine if I could get the syntax right I would be good to go.
The issue that I'm running into is my "-filter". The idea is IF WINS isn't set I don't want to enable it or change/set it to the new WINS server IP. Below is the script I have written, you can just ingore all the comments if you want. I do it for two reason 1st to help me understand the code/syntax better and second incase I want to reuse the script later it helps me rememeber what it does.
# here is where I read from the list of servers, this makes the entire list a variable $Server_List = Get-Content C:\Scripts\PS-Scripts\WINS\Test.txt foreach ($Server in $Server_List) # here is where I break the list into individual variables { # Since there could be more than one NIC I'm going to do the same for each NIC on the server # I'm going to put in a filter as well to make sure the NIC is enabled, DHCP is disabled, and WINS is enabled" # My list shouldn't include any servers with this but I'm going to include this filter for a failsafe, just in case. $Every_NIC_on_Server = Get-wmiObject Win32_networkadapterconfiguration -computername $Server -Filter "IPEnabled=TRUE and DHCPEnabled=FALSE and WINSPrimaryServer='0.0.0.0' and WINSSecondaryServer='0.0.0.0'" $Every_NIC_on_Server = Get-wmiObject Win32_networkadapterconfiguration -computername $Server -Filter "IPEnabled=TRUE and DHCPEnabled=FALSE and WINSEnableLMHostsLookup=TRUE and WINSPrimaryServer='' and WINSSecondaryServer=''" $Every_NIC_on_Server = Get-wmiObject Win32_networkadapterconfiguration -computername $Server -Filter "IPEnabled=TRUE and DHCPEnabled=FALSE and WINSEnableLMHostsLookup=TRUE and WINSPrimaryServer=$null and WINSSecondaryServer=$null" # http://social.technet.microsoft.com/Forums/en-US/6dc7f2b3-a906-4556-844b-9ac030ee6f24/remove-wins-entries-via-powershell?forum=winserverpowershell foreach ($Individual_NIC in $Every_NIC_on_Server) { # http://www.powershellpro.com/powershell-tutorial-introduction/powershell-wmi-methods/ $Individual_NIC.SetWINSServer("123.123.123.123","123.123.123.123") } }
Thanks in adavance for any and all help.