Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Win32_NetworkingAdapterConfiguration class and SetDNSSuffixSearchO

Reply
 
Old 05-02-2008   #1 (permalink)
Matt Duguid


 
 

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\Win32_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

My System SpecsSystem Spec
Old 05-02-2008   #2 (permalink)
Shay Levi


 
 

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","suffix2.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
Quote:

> 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\Win32_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
>

My System SpecsSystem Spec
Old 06-25-2008   #3 (permalink)
Kris


 
 

Re: Win32_NetworkingAdapterConfiguration class and SetDNSSuffixSea



"Shay Levi" wrote:
Quote:

>
> 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","suffix2.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
>
Quote:

> > 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\Win32_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
My System SpecsSystem Spec
Old 06-26-2008   #4 (permalink)
Shay Levi


 
 

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_NetworkAdapterConfiguration"
$nic.SetDNSSuffixSearchOrder(@("suffix1.com","suffix2.com","suffix3.com","suffix4.com"))


---
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com

K> "Shay Levi" wrote:
K>
Quote:
Quote:

>> 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","suffix2.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
Quote:

>>> 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\Win32_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>


My System SpecsSystem Spec
Old 06-26-2008   #5 (permalink)
Shay Levi


 
 

Re: Win32_NetworkingAdapterConfiguration class and SetDNSSuffixSea



BTW, you can also set it through the registry:

HKLM\System\CurrentControlSet\Services\TCPIP\Parameters\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>
Quote:
Quote:

>> 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","suffix2.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
Quote:

>>> 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\Win32_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>


My System SpecsSystem Spec
Old 06-27-2008   #6 (permalink)
Kris


 
 

Re: Win32_NetworkingAdapterConfiguration class and SetDNSSuffixSea

Hey, Shay

This is exactly what I typed in all though it was from a windows 2008 server
But setting throught the registry is working.
$server = "ServerName"
$nic = [wmiclass]"\\$server\ROOT\cimv2:Win32_NetworkAdapterConfiguration"
$nic.SetDNSSuffixSearchOrder(@("suffix1.com","suffix2.com","suffix3.com","suffix4.com"))

Thanks
For you help
Kris

"Shay Levi" wrote:
Quote:

> 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_NetworkAdapterConfiguration"
> $nic.SetDNSSuffixSearchOrder(@("suffix1.com","suffix2.com","suffix3.com","suffix4.com"))
>
>
> ---
> Shay Levi
> $cript Fanatic
> http://scriptolog.blogspot.com
>
> K> "Shay Levi" wrote:
> K>
Quote:
Quote:

> >> 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","suffix2.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\Win32_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>
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
When a class is both an inherited class of another, and alsoimplements an interface method .NET General
win32_pingstatus class / dns class PowerShell
Win32_Tpm class Vista security
win32reg_addremoveprograms class - where??? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46