TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Microsoft > Microsoft Windows Powershell

Notices

Reply
 
Thread Tools Display Modes
Old 02-05-2008, 11:47 AM   #1
Matt Duguid
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
  Reply With Quote
Old 02-05-2008, 01:45 PM   #2
Shay Levi
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
>



  Reply With Quote
Old 26-06-2008, 04:33 PM   #3
Kris
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
  Reply With Quote
Old 26-06-2008, 04:33 PM   #4
Shay Levi
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>


  Reply With Quote
Old 26-06-2008, 04:33 PM   #5
Shay Levi
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>


  Reply With Quote
Reply

Thread Tools
Display Modes


Google
 


All times are GMT +5.5. The time now is 02:19 AM.


vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2008, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional