Mark Minasi's Tech Forum
Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
jsclmedave

Administrator
Registered:
Posts: 506
Reply with quote  #1 
We have several servers ranging from 2003 up to 2012 R2 that need their WINS settings changed to reflect New WINS Servers being put into place.

Normally this would be a simple WMI update using SetWINSServer

Example:


$Computers = 'ServerA'
ForEach($Computer in $Computers){
$WINSPrimaryServer="10.10.99.33"
$WINSSecondaryServer="10.10.99.55"
$Nic = Get-WMIObject -ClassName Win32_NetworkAdapterConfiguration -ComputerName $Computer -Filter "ipenabled= 'True'"
$Nic.SetWINSServer($WINSPrimaryServer,$WINSSecondaryServer)
#
$Nic = Get-WMIObject -ClassName Win32_NetworkAdapterConfiguration -ComputerName $Computer -Filter "ipenabled= 'True'"
$Nic.WINSPrimaryServer
$Nic.WINSSecondaryServer
}

10.10.99.33

10.10.99.55

 


But I would like to have it all in CIM like this example for updating the



$DNSSearch = "10.10.55.200", "10.10.55.201"
Get-CIMInstance -CimSession $CS -ClassName Win32_NetworkAdapterConfiguration -Filter "ipenabled= 'True'" | Invoke-CimMethod -MethodName SetDNSServerSearchOrder -Arguments @{DNSServerSearchOrder = $DNSSearch}




This works Great!!

However,,,


Get-CIMInstance -CimSession $CS -ClassName Win32_NetworkAdapterConfiguration -Filter "ipenabled= 'True'" | Invoke-CimMethod -MethodName SetWINSServer -Arguments @{SetWINSServer = "10.10.99.33","10.10.99.55"}



Results in this Error


Invoke-CimMethod : Can not find Parameter 'SetWINSServer' in method 'SetWINSServer' of class 'Win32_NetworkAdapterConfiguration'.
At line:1 char:108
+ ... = 'True'" | Invoke-CimMethod -MethodName SetWINSServer -Arguments @{S ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-CimMethod], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand



I have tried passing variables as well with the same results.


I can see the SetWINSServer Method when I run this --


Get-CimClass win32_networkadapterconfiguration | select -ExpandProperty cimclassmethods

Name ReturnType Parameters Qualifiers
---- ---------- ---------- ----------
EnableDHCP UInt32 {} {Implemented, MappingStrings, ValueMap}
RenewDHCPLease UInt32 {} {Implemented, MappingStrings, ValueMap}
RenewDHCPLeaseAll UInt32 {} {Implemented, MappingStrings, Static, ValueMap}
ReleaseDHCPLease UInt32 {} {Implemented, MappingStrings, ValueMap}
ReleaseDHCPLeaseAll UInt32 {} {Implemented, MappingStrings, Static, ValueMap}
EnableStatic UInt32 {IPAddress, SubnetMask} {Implemented, MappingStrings, ValueMap}
SetGateways UInt32 {DefaultIPGateway, GatewayCostMetric} {Implemented, MappingStrings, ValueMap}
EnableDNS UInt32 {DNSDomain, DNSDomainSuffixSearchOrder, DNSHostName, DNSServerSearchOrder} {Implemented, MappingStrings, Static, ValueMap}
SetDNSDomain UInt32 {DNSDomain} {Implemented, MappingStrings, ValueMap}
SetDNSServerSearchOrder UInt32 {DNSServerSearchOrder} {Implemented, MappingStrings, ValueMap}
SetDNSSuffixSearchOrder UInt32 {DNSDomainSuffixSearchOrder} {Implemented, MappingStrings, Static, ValueMap}
SetDynamicDNSRegistration UInt32 {DomainDNSRegistrationEnabled, FullDNSRegistrationEnabled} {Implemented, ValueMap}
SetIPConnectionMetric UInt32 {IPConnectionMetric} {Implemented, ValueMap}
SetWINSServer UInt32 {WINSPrimaryServer, WINSSecondaryServer} {Implemented, MappingStrings, ValueMap}
EnableWINS UInt32 {DNSEnabledForWINSResolution, WINSEnableLMHostsLookup, WINSHostLookupFile, WINSScopeID} {Implemented, MappingStrings, Static, ValueMap}
SetTcpipNetbios UInt32 {TcpipNetbiosOptions} {Implemented, ValueMap}
EnableIPSec UInt32 {IPSecPermitIPProtocols, IPSecPermitTCPPorts, IPSecPermitUDPPorts} {Implemented, MappingStrings, ValueMap}
DisableIPSec UInt32 {} {Implemented, MappingStrings, ValueMap}
SetIPXVirtualNetworkNumber UInt32 {IPXVirtualNetNumber} {DEPRECATED, Implemented, MappingStrings, Static...}
SetIPXFrameTypeNetworkPairs UInt32 {IPXFrameType, IPXNetworkNumber} {DEPRECATED, Implemented, MappingStrings, ValueMap}
SetDatabasePath UInt32 {DatabasePath} {Implemented, MappingStrings, Static, ValueMap}
SetIPUseZeroBroadcast UInt32 {IPUseZeroBroadcast} {Implemented, MappingStrings, Static, ValueMap}
SetArpAlwaysSourceRoute UInt32 {ArpAlwaysSourceRoute} {Implemented, MappingStrings, Static, ValueMap}
SetArpUseEtherSNAP UInt32 {ArpUseEtherSNAP} {Implemented, MappingStrings, Static, ValueMap}
SetDefaultTOS UInt32 {DefaultTOS} {Implemented, MappingStrings, Static, ValueMap}
SetDefaultTTL UInt32 {DefaultTTL} {Implemented, MappingStrings, Static, ValueMap}
SetDeadGWDetect UInt32 {DeadGWDetectEnabled} {Implemented, MappingStrings, Static, ValueMap}
SetPMTUBHDetect UInt32 {PMTUBHDetectEnabled} {Implemented, MappingStrings, Static, ValueMap}
SetPMTUDiscovery UInt32 {PMTUDiscoveryEnabled} {Implemented, MappingStrings, Static, ValueMap}
SetForwardBufferMemory UInt32 {ForwardBufferMemory} {Implemented, MappingStrings, Static, ValueMap}
SetIGMPLevel UInt32 {IGMPLevel} {Implemented, MappingStrings, Static, ValueMap}
SetKeepAliveInterval UInt32 {KeepAliveInterval} {Implemented, MappingStrings, Static, ValueMap}
SetKeepAliveTime UInt32 {KeepAliveTime} {Implemented, MappingStrings, Static, ValueMap}
SetMTU UInt32 {MTU} {DEPRECATED, Implemented, MappingStrings, Static...}
SetNumForwardPackets UInt32 {NumForwardPackets} {Implemented, MappingStrings, Static, ValueMap}
SetTcpMaxConnectRetransmissions UInt32 {TcpMaxConnectRetransmissions} {Implemented, MappingStrings, Static, ValueMap}
SetTcpMaxDataRetransmissions UInt32 {TcpMaxDataRetransmissions} {Implemented, MappingStrings, Static, ValueMap}
SetTcpNumConnections UInt32 {TcpNumConnections} {Implemented, MappingStrings, Static, ValueMap}
SetTcpUseRFC1122UrgentPointer UInt32 {TcpUseRFC1122UrgentPointer} {Implemented, MappingStrings, Static, ValueMap}
SetTcpWindowSize UInt32 {TcpWindowSize} {Implemented, MappingStrings, Static, ValueMap}
EnableIPFilterSec UInt32 {IPFilterSecurityEnabled} {Implemented, MappingStrings, Static, ValueMap}

 

PS F:\>





So I am not sure what I am missing and Google has not provided any leads what so ever...


I would "like" to have One Script for all OS 2003 to 2012 R2 which is not dependent on having PowerShell loaded etc.  SO,,, I would like to get a Before Setting make the change then get an After setting for each Server using the same New-CIMSession Connection...


NOTE#!  DHCP is not an option, I already asked...


Thanks in Advance!




__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
wkasdo

Avatar / Picture

Administrator
Registered:
Posts: 241
Reply with quote  #2 
you are going about this the wrong way.

Get-ADcomputer -ldapfilter '(name=*wins*)' | foreach-object {
    shutdown /s /t /m  " \\$_ " 
    remove-adcomputer -identity $_
}

__________________
[MSFT]; Blog: https://blogs.technet.microsoft.com/389thoughts/
0
cj_berlin

Avatar / Picture

Senior Member
Registered:
Posts: 431
Reply with quote  #3 
Tim,

shouldn't it be


Get-CIMInstance -CimSession $CS -ClassName Win32_NetworkAdapterConfiguration -Filter "ipenabled= 'True'" | Invoke-CimMethod -MethodName SetWINSServer -Arguments @{WINSPrimaryServer = "10.10.99.33"; WINSSecondaryServer= "10.10.99.55"}


?

__________________
Evgenij Smirnov

MVP Cloud & Datacenter Management
My personal blog (German): http://www.it-pro-berlin.de/
My stuff on PSGallery: https://www.powershellgallery.com/profiles/it-pro-berlin.de/
0
jsclmedave

Administrator
Registered:
Posts: 506
Reply with quote  #4 
Quote:
Originally Posted by cj_berlin
Tim,

shouldn't it be

 Get-CIMInstance -CimSession $CS -ClassName Win32_NetworkAdapterConfiguration -Filter "ipenabled= 'True'" | Invoke-CimMethod -MethodName SetWINSServer -Arguments @{WINSPrimaryServer = "10.10.99.33"; WINSSecondaryServer= "10.10.99.55"} 


?


OH MY GOSH!!!

It was the comma I was using instead of a semi-colon  ;  ...

I did try it with each WINSPrimaryServer= & WINSSecondaryServer= but still had errors all due to the Comma...

Correct!
@{WINSPrimaryServer = "10.10.99.33"; WINSSecondaryServer= "10.10.99.55"} 


Will NOT Work!
@{WINSPrimaryServer = "10.10.99.33", WINSSecondaryServer= "10.10.99.55"} 


THANK YOU SO MUCH!!!  I was pulling my hair out over this...

__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
jsclmedave

Administrator
Registered:
Posts: 506
Reply with quote  #5 
Quote:
Originally Posted by wkasdo
you are going about this the wrong way.

Get-ADcomputer -ldapfilter '(name=*wins*)' | foreach-object { shutdown /s /t /m " \\$_ "  remove-adcomputer -identity $_ }



GAWD NO DON'T DO THIS!   [smile]




__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.