![]() |
|
|||||||
| Notices |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Win32_NetworkingAdapterConfiguration class and SetDNSSuffixSearchO
So I have some Powershell code which I am using to set the variables on the
TCP/IP stack of a Windows 2008 Web server. So far I have successfully set "IP Address", "Subnet Mask", "Gateway", "DNS Servers" but cannot set the "DNSSuffixSearchorder". When I try Powershell tells me the method doesn't exist. The error I receive is... Method invocation failed because [System.Management.ManagementObject#root\cimv2\Win3 2_NetworkingAdapterConfiguration] doesn't contain a method named 'SetDNSSuffixSearchOrder'. The code I am using is... $DNSSuffixes = @("domain.com", "subdomain1.domain.com", "subdomain2.domain.com") Get-WmiObject -class win32_networkadapterconfiguration | where-object -filterscript { $_.IPEnabled -eq ‘True’ } | foreach-object -process { $_.SetDNSSuffixSearchOrder($DNSSuffixes) } A check with the windows tool WBEMTEST shows a method called "SetDNSSuffixSearchOrder" under the "win32_networkadapterconfiguration" class. A check of the Microsoft website document "http://msdn.microsoft.com/en-us/library/aa393296(VS.85).aspx" states "The SetDNSSuffixSearchOrder WMI class static *****method***** uses an array of string elements to set the suffix search order. Notice the bit surrounded in *****'s ![]() A check in powershell using the Get-Member cmdlet shows no "SetDNSSuffixSearchOrder" method but does show a "DNSDomainSuffixSearchOrder" property. So what going wrong here? If anyone can help shed light on this little puppy next time your in New Zealand I'll buy you a beer or two...honest...I have been banging my head against the wall for a wee while on this. Matt Duguid |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: Win32_NetworkingAdapterConfiguration class and SetDNSSuffixSearchO
Hi Matt, You need to bind to the win32_networkadapterconfiguration class to get reference to SetDNSSuffixSearchOrder() as it is a static method (not available on the class instances): Get-WmiObject -list win32_networkadapterconfiguration | gm set* - or the [wmiclass] type accelerator - [wmiclass] "win32_networkadapterconfiguration" | gm set* Try: $nic = [wmiclass] "win32_networkadapterconfiguration" $nic.SetDNSSuffixSearchOrder(@("suffix1.com","suff ix2.com","suffix3.com","suffix4.com")) BTW, when you compare against boolean values, instead of true/false use $true/$false. Here are some options for boolean comparisons: to compare for true: where { $_.IPEnabled -eq $true} or simply: where { $_.IPEnabled } and for false values (all are the same): 1. where { $_.IPEnabled -eq $false} 2. where { -not$_.IPEnabled } 3. where { !$_.IPEnabled } Choose your favorite ![]() ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com > So I have some Powershell code which I am using to set the variables > on the TCP/IP stack of a Windows 2008 Web server. > > So far I have successfully set "IP Address", "Subnet Mask", "Gateway", > "DNS Servers" but cannot set the "DNSSuffixSearchorder". When I try > Powershell tells me the method doesn't exist. > > The error I receive is... > > Method invocation failed because > [System.Management.ManagementObject#root\cimv2\Win3 2_NetworkingAdapter > Configuration] doesn't contain a method named > 'SetDNSSuffixSearchOrder'. > > The code I am using is... > > $DNSSuffixes = @("domain.com", "subdomain1.domain.com", > "subdomain2.domain.com") > > Get-WmiObject -class win32_networkadapterconfiguration | where-object > -filterscript { $_.IPEnabled -eq ‘True’ } | foreach-object -process { > $_.SetDNSSuffixSearchOrder($DNSSuffixes) } > > A check with the windows tool WBEMTEST shows a method called > "SetDNSSuffixSearchOrder" under the > "win32_networkadapterconfiguration" class. > > A check of the Microsoft website document > "http://msdn.microsoft.com/en-us/library/aa393296(VS.85).aspx" states > "The SetDNSSuffixSearchOrder WMI class static *****method***** uses an > array of string elements to set the suffix search order. Notice the > bit surrounded in *****'s ![]() > > A check in powershell using the Get-Member cmdlet shows no > "SetDNSSuffixSearchOrder" method but does show a > "DNSDomainSuffixSearchOrder" property. > > So what going wrong here? If anyone can help shed light on this little > puppy next time your in New Zealand I'll buy you a beer or > two...honest...I have been banging my head against the wall for a wee > while on this. > > Matt Duguid > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: Win32_NetworkingAdapterConfiguration class and SetDNSSuffixSea
"Shay Levi" wrote: > > Hi Matt, > > > > You need to bind to the win32_networkadapterconfiguration class to get reference > to SetDNSSuffixSearchOrder() as it is a static method (not available on the > class instances): > > > Get-WmiObject -list win32_networkadapterconfiguration | gm set* > > - or the [wmiclass] type accelerator - > > [wmiclass] "win32_networkadapterconfiguration" | gm set* > > > > Try: > > $nic = [wmiclass] "win32_networkadapterconfiguration" > $nic.SetDNSSuffixSearchOrder(@("suffix1.com","suff ix2.com","suffix3.com","suffix4.com")) > > > > BTW, when you compare against boolean values, instead of true/false use $true/$false. > Here are some options for boolean comparisons: > > > to compare for true: > > where { $_.IPEnabled -eq $true} > > or simply: > > where { $_.IPEnabled } > > > > and for false values (all are the same): > > 1. where { $_.IPEnabled -eq $false} > 2. where { -not$_.IPEnabled } > 3. where { !$_.IPEnabled } > > > Choose your favorite ![]() > > > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > > > So I have some Powershell code which I am using to set the variables > > on the TCP/IP stack of a Windows 2008 Web server. > > > > So far I have successfully set "IP Address", "Subnet Mask", "Gateway", > > "DNS Servers" but cannot set the "DNSSuffixSearchorder". When I try > > Powershell tells me the method doesn't exist. > > > > The error I receive is... > > > > Method invocation failed because > > [System.Management.ManagementObject#root\cimv2\Win3 2_NetworkingAdapter > > Configuration] doesn't contain a method named > > 'SetDNSSuffixSearchOrder'. > > > > The code I am using is... > > > > $DNSSuffixes = @("domain.com", "subdomain1.domain.com", > > "subdomain2.domain.com") > > > > Get-WmiObject -class win32_networkadapterconfiguration | where-object > > -filterscript { $_.IPEnabled -eq ‘True’ } | foreach-object -process { > > $_.SetDNSSuffixSearchOrder($DNSSuffixes) } > > > > A check with the windows tool WBEMTEST shows a method called > > "SetDNSSuffixSearchOrder" under the > > "win32_networkadapterconfiguration" class. > > > > A check of the Microsoft website document > > "http://msdn.microsoft.com/en-us/library/aa393296(VS.85).aspx" states > > "The SetDNSSuffixSearchOrder WMI class static *****method***** uses an > > array of string elements to set the suffix search order. Notice the > > bit surrounded in *****'s ![]() > > > > A check in powershell using the Get-Member cmdlet shows no > > "SetDNSSuffixSearchOrder" method but does show a > > "DNSDomainSuffixSearchOrder" property. > > > > So what going wrong here? If anyone can help shed light on this little > > puppy next time your in New Zealand I'll buy you a beer or > > two...honest...I have been banging my head against the wall for a wee > > while on this. > > > > Matt Duguid > > > > > Hey I tried to set the dns suffix with the above script but there is no change on the computer I am trying to change. I get the following out put but no change. __GENUS : 2 __CLASS : __PARAMETERS __SUPERCLASS : __DYNASTY : __PARAMETERS __RELPATH : __PROPERTY_COUNT : 1 __DERIVATION : {} __SERVER : ServerName __NAMESPACE : root\cimv2 __PATH : ReturnValue : 0 any suggestions would be great |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Re: Win32_NetworkingAdapterConfiguration class and SetDNSSuffixSea
Hi Kris,
Can you try this, it is working for me, locally or remotely (xp or vista): $server = "ServerName" $nic = [wmiclass]"\\$server\ROOT\cimv2:Win32_NetworkAdapterConfigur ation" $nic.SetDNSSuffixSearchOrder(@("suffix1.com","suff ix2.com","suffix3.com","suffix4.com")) --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com K> "Shay Levi" wrote: K> >> Hi Matt, >> >> You need to bind to the win32_networkadapterconfiguration class to >> get reference to SetDNSSuffixSearchOrder() as it is a static method >> (not available on the class instances): >> >> Get-WmiObject -list win32_networkadapterconfiguration | gm set* >> >> - or the [wmiclass] type accelerator - >> >> [wmiclass] "win32_networkadapterconfiguration" | gm set* >> >> Try: >> >> $nic = [wmiclass] "win32_networkadapterconfiguration" >> $nic.SetDNSSuffixSearchOrder(@("suffix1.com","suff ix2.com","suffix3.c >> om","suffix4.com")) >> >> BTW, when you compare against boolean values, instead of true/false >> use $true/$false. Here are some options for boolean comparisons: >> >> to compare for true: >> >> where { $_.IPEnabled -eq $true} >> >> or simply: >> >> where { $_.IPEnabled } >> >> and for false values (all are the same): >> >> 1. where { $_.IPEnabled -eq $false} >> 2. where { -not$_.IPEnabled } >> 3. where { !$_.IPEnabled } >> Choose your favorite ![]() >> >> ----- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com >>> So I have some Powershell code which I am using to set the variables >>> on the TCP/IP stack of a Windows 2008 Web server. >>> >>> So far I have successfully set "IP Address", "Subnet Mask", >>> "Gateway", "DNS Servers" but cannot set the "DNSSuffixSearchorder". >>> When I try Powershell tells me the method doesn't exist. >>> >>> The error I receive is... >>> >>> Method invocation failed because >>> [System.Management.ManagementObject#root\cimv2\Win3 2_NetworkingAdapt >>> er Configuration] doesn't contain a method named >>> 'SetDNSSuffixSearchOrder'. >>> >>> The code I am using is... >>> >>> $DNSSuffixes = @("domain.com", "subdomain1.domain.com", >>> "subdomain2.domain.com") >>> >>> Get-WmiObject -class win32_networkadapterconfiguration | >>> where-object -filterscript { $_.IPEnabled -eq ‘True’ } | >>> foreach-object -process { $_.SetDNSSuffixSearchOrder($DNSSuffixes) } >>> >>> A check with the windows tool WBEMTEST shows a method called >>> "SetDNSSuffixSearchOrder" under the >>> "win32_networkadapterconfiguration" class. >>> >>> A check of the Microsoft website document >>> "http://msdn.microsoft.com/en-us/library/aa393296(VS.85).aspx" >>> states "The SetDNSSuffixSearchOrder WMI class static >>> *****method***** uses an array of string elements to set the suffix >>> search order. Notice the bit surrounded in *****'s ![]() >>> >>> A check in powershell using the Get-Member cmdlet shows no >>> "SetDNSSuffixSearchOrder" method but does show a >>> "DNSDomainSuffixSearchOrder" property. >>> >>> So what going wrong here? If anyone can help shed light on this >>> little puppy next time your in New Zealand I'll buy you a beer or >>> two...honest...I have been banging my head against the wall for a >>> wee while on this. >>> >>> Matt Duguid >>> >> Hey >> K> I tried to set the dns suffix with the above script but there is no K> change on the computer I am trying to change. I get the following out K> put but no change. K> K> __GENUS : 2 K> __CLASS : __PARAMETERS K> __SUPERCLASS : K> __DYNASTY : __PARAMETERS K> __RELPATH : K> __PROPERTY_COUNT : 1 K> __DERIVATION : {} K> __SERVER : ServerName K> __NAMESPACE : root\cimv2 K> __PATH : K> ReturnValue : 0 K> any suggestions would be great K> |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Re: Win32_NetworkingAdapterConfiguration class and SetDNSSuffixSea
BTW, you can also set it through the registry: HKLM\System\CurrentControlSet\Services\TCPIP\Param eters\SearchList Just update/create the above reg value (REG_SZ) with a value like: "suffix1.com,suffix2.com,suffix3.com" You can find a set of registry functions on my blog: http://scriptolog.blogspot.com/2007/...s-library.html --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com K> "Shay Levi" wrote: K> >> Hi Matt, >> >> You need to bind to the win32_networkadapterconfiguration class to >> get reference to SetDNSSuffixSearchOrder() as it is a static method >> (not available on the class instances): >> >> Get-WmiObject -list win32_networkadapterconfiguration | gm set* >> >> - or the [wmiclass] type accelerator - >> >> [wmiclass] "win32_networkadapterconfiguration" | gm set* >> >> Try: >> >> $nic = [wmiclass] "win32_networkadapterconfiguration" >> $nic.SetDNSSuffixSearchOrder(@("suffix1.com","suff ix2.com","suffix3.c >> om","suffix4.com")) >> >> BTW, when you compare against boolean values, instead of true/false >> use $true/$false. Here are some options for boolean comparisons: >> >> to compare for true: >> >> where { $_.IPEnabled -eq $true} >> >> or simply: >> >> where { $_.IPEnabled } >> >> and for false values (all are the same): >> >> 1. where { $_.IPEnabled -eq $false} >> 2. where { -not$_.IPEnabled } >> 3. where { !$_.IPEnabled } >> Choose your favorite ![]() >> >> ----- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com >>> So I have some Powershell code which I am using to set the variables >>> on the TCP/IP stack of a Windows 2008 Web server. >>> >>> So far I have successfully set "IP Address", "Subnet Mask", >>> "Gateway", "DNS Servers" but cannot set the "DNSSuffixSearchorder". >>> When I try Powershell tells me the method doesn't exist. >>> >>> The error I receive is... >>> >>> Method invocation failed because >>> [System.Management.ManagementObject#root\cimv2\Win3 2_NetworkingAdapt >>> er Configuration] doesn't contain a method named >>> 'SetDNSSuffixSearchOrder'. >>> >>> The code I am using is... >>> >>> $DNSSuffixes = @("domain.com", "subdomain1.domain.com", >>> "subdomain2.domain.com") >>> >>> Get-WmiObject -class win32_networkadapterconfiguration | >>> where-object -filterscript { $_.IPEnabled -eq ‘True’ } | >>> foreach-object -process { $_.SetDNSSuffixSearchOrder($DNSSuffixes) } >>> >>> A check with the windows tool WBEMTEST shows a method called >>> "SetDNSSuffixSearchOrder" under the >>> "win32_networkadapterconfiguration" class. >>> >>> A check of the Microsoft website document >>> "http://msdn.microsoft.com/en-us/library/aa393296(VS.85).aspx" >>> states "The SetDNSSuffixSearchOrder WMI class static >>> *****method***** uses an array of string elements to set the suffix >>> search order. Notice the bit surrounded in *****'s ![]() >>> >>> A check in powershell using the Get-Member cmdlet shows no >>> "SetDNSSuffixSearchOrder" method but does show a >>> "DNSDomainSuffixSearchOrder" property. >>> >>> So what going wrong here? If anyone can help shed light on this >>> little puppy next time your in New Zealand I'll buy you a beer or >>> two...honest...I have been banging my head against the wall for a >>> wee while on this. >>> >>> Matt Duguid >>> >> Hey >> K> I tried to set the dns suffix with the above script but there is no K> change on the computer I am trying to change. I get the following out K> put but no change. K> K> __GENUS : 2 K> __CLASS : __PARAMETERS K> __SUPERCLASS : K> __DYNASTY : __PARAMETERS K> __RELPATH : K> __PROPERTY_COUNT : 1 K> __DERIVATION : {} K> __SERVER : ServerName K> __NAMESPACE : root\cimv2 K> __PATH : K> ReturnValue : 0 K> any suggestions would be great K> |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|