List servers and their DNS server settings

I am trying to get a list of server names and their primary and secondary 
DNS server settings.

If I try the following command:

get-wmiobject Win32_networkadapterconfiguration -computername "servername | 
select name, DNSServerSearchOrder

It would give me the specific servername and its dns addresses.

I know have a list of computernames which I would like to list out and their 
DNSserversearchorder settings (DNS settings)

I tried putting the list of computernames in a text file by using 
get-qadcomputer | export-csv C:\computername.txt -notype

Then I used the get-content command and the piped into the get-wmiobject 
command like below:

$servers = Get-Content c:\computername.txt

ForEach ($server in $servers)
{ get-wmiobject Win32_networkadapterconfiguration -computername $server
| where{$_.IPEnabled -match "True"} | select-object
name,DNSServerSearchOrder

But when I run this command it fails with errors such as an empty pipe 
element is not permitted.  I dont know if the above script has any synatx 
errors or what is the best way to get a list of servers and their dns server 
settings.

Can anyone please advise 


0
guv
6/8/2010 12:09:45 PM
windows.powershell 690 articles. 0 followers. Follow

3 Replies
2316 Views

Similar Articles

[PageSpeed] 1

ForEach does not return output to the pipeline, although you can 
work-around that be executing it as a script block. ForEach-Object does. 
May as well skip the file as well.

Get-QADComputer  | ForEach-Object {
  Get-WmiObject Win32_NetworkAdapterConfiguration -Computername $_.Name 
-Filter "IPEnabled=$True" |
    Select-Object Name, DNSServerSearchOrder
}

HTH

Chris

guv wrote:
> I am trying to get a list of server names and their primary and secondary 
> DNS server settings.
>
> If I try the following command:
>
> get-wmiobject Win32_networkadapterconfiguration -computername "servername | 
> select name, DNSServerSearchOrder
>
> It would give me the specific servername and its dns addresses.
>
> I know have a list of computernames which I would like to list out and their 
> DNSserversearchorder settings (DNS settings)
>
> I tried putting the list of computernames in a text file by using 
> get-qadcomputer | export-csv C:\computername.txt -notype
>
> Then I used the get-content command and the piped into the get-wmiobject 
> command like below:
>
> $servers = Get-Content c:\computername.txt
>
> ForEach ($server in $servers)
> { get-wmiobject Win32_networkadapterconfiguration -computername $server
> | where{$_.IPEnabled -match "True"} | select-object
> name,DNSServerSearchOrder
>
> But when I run this command it fails with errors such as an empty pipe 
> element is not permitted.  I dont know if the above script has any synatx 
> errors or what is the best way to get a list of servers and their dns server 
> settings.
>
> Can anyone please advise 
>
>
>   
0
Chris
6/8/2010 12:23:55 PM
If I run the script :

Get-Content c:\computername.txt | `

ForEach-Object {

  Get-WMIObject Win32_NetworkAdapterConfiguration -Computername $_ | `

    Where-Object {$_.IPEnabled -match "True"} | `

    Select-Object -property DNSHostName,DNSServerSearchOrder }



And in the computername.txt file I list the servers as :



server1

server2.



On the command line it displays the dnshostname and the dnsserversearchorder 
as IP address values.



But when i import the script to a csv file like if i called the script 
dns.ps1 and then run the following command:



../dns.ps1 | export.csv c:\servers.csv



the dnsserversearchorder values are displayed as System.String[] in the csv 
file and not the IP addresses of the DNS servers. The DNShostname is 
displayed fine. Any reason why this is happening and how i can the ipaddress 
values in a csv or txt file to be displayed.

"guv" <guv@> wrote in message news:OUM$1NwBLHA.3840@TK2MSFTNGP02.phx.gbl...
>I am trying to get a list of server names and their primary and secondary 
>DNS server settings.
>
> If I try the following command:
>
> get-wmiobject Win32_networkadapterconfiguration -computername "servername 
> | select name, DNSServerSearchOrder
>
> It would give me the specific servername and its dns addresses.
>
> I know have a list of computernames which I would like to list out and 
> their DNSserversearchorder settings (DNS settings)
>
> I tried putting the list of computernames in a text file by using 
> get-qadcomputer | export-csv C:\computername.txt -notype
>
> Then I used the get-content command and the piped into the get-wmiobject 
> command like below:
>
> $servers = Get-Content c:\computername.txt
>
> ForEach ($server in $servers)
> { get-wmiobject Win32_networkadapterconfiguration -computername $server
> | where{$_.IPEnabled -match "True"} | select-object
> name,DNSServerSearchOrder
>
> But when I run this command it fails with errors such as an empty pipe 
> element is not permitted.  I dont know if the above script has any synatx 
> errors or what is the best way to get a list of servers and their dns 
> server settings.
>
> Can anyone please advise
> 


0
guv
6/8/2010 1:35:21 PM
This will get you a list of servers in a string rather than as an array.

Select-Object DnsHostName, @{n='DNSServers';e={ 
"$($_.DnsServerSearchOrder)" }}

guv wrote:
> If I run the script :
>
> Get-Content c:\computername.txt | `
>
> ForEach-Object {
>
>   Get-WMIObject Win32_NetworkAdapterConfiguration -Computername $_ | `
>
>     Where-Object {$_.IPEnabled -match "True"} | `
>
>     Select-Object -property DNSHostName,DNSServerSearchOrder }
>
>
>
> And in the computername.txt file I list the servers as :
>
>
>
> server1
>
> server2.
>
>
>
> On the command line it displays the dnshostname and the dnsserversearchorder 
> as IP address values.
>
>
>
> But when i import the script to a csv file like if i called the script 
> dns.ps1 and then run the following command:
>
>
>
> ./dns.ps1 | export.csv c:\servers.csv
>
>
>
> the dnsserversearchorder values are displayed as System.String[] in the csv 
> file and not the IP addresses of the DNS servers. The DNShostname is 
> displayed fine. Any reason why this is happening and how i can the ipaddress 
> values in a csv or txt file to be displayed.
>
> "guv" <guv@> wrote in message news:OUM$1NwBLHA.3840@TK2MSFTNGP02.phx.gbl...
>   
>> I am trying to get a list of server names and their primary and secondary 
>> DNS server settings.
>>
>> If I try the following command:
>>
>> get-wmiobject Win32_networkadapterconfiguration -computername "servername 
>> | select name, DNSServerSearchOrder
>>
>> It would give me the specific servername and its dns addresses.
>>
>> I know have a list of computernames which I would like to list out and 
>> their DNSserversearchorder settings (DNS settings)
>>
>> I tried putting the list of computernames in a text file by using 
>> get-qadcomputer | export-csv C:\computername.txt -notype
>>
>> Then I used the get-content command and the piped into the get-wmiobject 
>> command like below:
>>
>> $servers = Get-Content c:\computername.txt
>>
>> ForEach ($server in $servers)
>> { get-wmiobject Win32_networkadapterconfiguration -computername $server
>> | where{$_.IPEnabled -match "True"} | select-object
>> name,DNSServerSearchOrder
>>
>> But when I run this command it fails with errors such as an empty pipe 
>> element is not permitted.  I dont know if the above script has any synatx 
>> errors or what is the best way to get a list of servers and their dns 
>> server settings.
>>
>> Can anyone please advise
>>
>>     
>
>
>   
0
Chris
6/8/2010 2:52:41 PM
Reply:

Similar Artilces:

System Setting not available
I am not able to create users because System under Settings is greyed out. I am logged on as SA. I am using GP 7.5. Help? Who is dbo for the DYNAMICS database? If it is other than 'sa' or 'DYNSA', such as 'administrator', run sp_changedbowner 'DYNSA'. Has this been a working GP system, or are you trying to restore to a new server? "Tiffany" wrote: > I am not able to create users because System under Settings is greyed out. > I am logged on as SA. I am using GP 7.5. Help? > > > It is just sa. We installed the app on...

Exchange2000 POP3 virtual server could not start
I have a mail server using Win2k SBS and ExchangerServer2000, the status of Microsoft POP service was started, but the POP3 virtual server in Exchange System Manager could not start, and it hang for a long time when I try to start . then I have to restart my computer...pls help me , thanks a lot!! Do you see anything in the application event log? -- Bharat Suneja MCSE, MCT www.zenprise.com blog: www.suneja.com/blog ----------------------------------------- "charles" <charles@discussions.microsoft.com> wrote in message news:1AA045A2-40C2-4709-82A1-5F59C214B18E@microsoft....

Running sql server 2000 and/or sql server 2005 on sbs 2003
My ultimate questions will be: Can SQL SErver 2000 and 2005 run on the same ssbs2003 server? and, regardless, Should I/ can I uninstall SQL Server 2005 and go back to SQL Server 2000. Moving from SBS2000 Premium to SBS2003 Premium on a new server. We were using SQL Server 2000 on the old server for a few things: Backup Exec, Prolog (construction mgmnt software), Great Plains (MS financial), etc. During the install, I kind of just followed directions and installed R2, which I guess installed SQL Server 2005. I wasn't really aware of options. Since then I have had a number ...

Reported error (0X800CC0F) the connection to the server was interrupted
I am receiving this error message on a client workstation, none of the other 4 users on the LAN are receiving this error. They are using Outlook 2002 connected through an ADSL modem. The user still can send and receive e-mails but this error message always appears. Any one have any ideas? Reported error (0X800CC0F) the connection to the server was interrupted Sean For those of you that have been getting "Sending and Receiving reported error .... connection to server was interrupted" as I have, try creating a new HTTP email account, send and receive a couple of messages from that...

CROSS-POST (also on General)
Hi, when I right-click in the folder list to create a new sub- folder I get an error: >>>> ERROR MSG >>>> Outlook can't read the registry information - Close and restart Outlook - Reinstall Outlook - Reinstall Microsoft Exchange or other e-mail system <<<< END <<<<< we have tried everything, including re-install of Office 2000. We have run this on Windows 2000 Professional.... please help if you have an answer thanks Philip When this error occurred on a Win XP machine (running Outlook 2002), I did a System Restore to fix it. If ...

Outlook Plain Text Setting
I am starting to move my users over to Outlook and Exchange 2003. I noticed that by default Outlook is setting the users up as HTML e-mail. Is there a way that I can set all of my users up with Plain Text for e-mail? Thanks, Jeff That is a user setting, of course, under Tools-->Options-->Mail Format You can use the following to ensure inbound email is read as plain text, and therefor replies will be plain text: http://www.outlook-tips.net/howto/plain_text.htm "Jeff Grossman" <jeff.nospam@stikman.com> wrote in message news:lcr542hthnrf6qfqikqrm4cdebs11ikuaa@4ax.co...

XML Map
Hi all, I import XML data into a worksheet, and choose a mapping name, but I have no idea how to change the path so that it is dynamic. I've been trying to find a way to set my mapping paths to dynamic, so that when I move the folder that contains the xl file and xml files, the mapping path still works. Help :) Cheers, Grant. I'm not sure you can make it 'dynamic' per se but you can write code to change. Here's a sample of changing the bound xml document. ActiveWorkbook.XmlMaps(1).DataBinding.LoadSettings ("C:\Services Proposal.xml") -- Charles...

Entourage loosing connection with server
Greetings All, Situation: At our work we use Entourage to connect to the Exchange server. It's been working great until about a week ago. We're running Office 2008, 12.2.3. Mac's are running 10.6.2. We loose connection with the server (can't receive or send mail). Quitting and restarting Entourage doesn't solve it. What DOES solve it is completely rebooting our Macs. Obviously a pain in the rumpus maximus! Has anyone experienced this? Any thoughts as to solving this? Many thanks in advance for your collective wisdom! Dan a <William.Reed@sbcusd.k12.ca...

Updating 2004 FI list
Does anyone know how to update Money 2004's Financial Institution list? When I check to see if my FI is online and supported, it is. When I check the Money 2004 list, it is not there. Any solutions? Thank you, any help would be great. -- Thanks, Andrew ...

Programmatically listing Relationships of ADP file
I'm fairly new to access and would like to get a listing of the relationships in the ADP file. How would I go about doing that programmatically? I haven't the first idea of where to start. I did find something that said to loop through the relationships collection, but I can't seem to find it. FWIW, I'm fairly fluent in Excel VBA. Thanks, Barb Reinhardt On Tue, 23 Mar 2010 12:30:01 -0700, Barb Reinhardt <BarbReinhardt@discussions.microsoft.com> wrote: A good start would be to open a VBA window, click the Help button, and look for Relationships...

Deleted Distribution List
Hi , LONG time Outlook user here..and I'm stumped ! I accidentally deleted a Distribution list from my Outlook 2007 contacts this afternoon. Immediately , I tried EDIT >UNDO , but it was greyed out. I searched Deleted Items in Mail ( thinking all deleted Outlook items ended up there ) and I couldn't find it. I searched Personal Folders as well ..but still no joy. I ended up recreating it , but the question remains , ..." Where did it go ?? " ( in case I do it again..) Many Thanks Next time it happens simply restore it from your backup. What, yo...

There is not enough space on the Exchange Server to store all of your rules.
Here is the problem we are having. We have been doing a server upgrade for a domain. The new and old servers are running Windows NT 4.0 and Microsoft Exchange Server 5.5. The Exchange Server was installed on the old PDC, but according to government standards, it must be located on the new BDC. We used the ExMerge utility to backup all user mailboxes (approximately 130) to a workstation. We then restored the mailboxes to the new BDC where they belonged. All users are able to access their old mail, and all of their old folders. Unfortunately, when some users try to activate the ru...

alphabetical list
ok...I have complied a list of my DVD collection and what I am trying to do is alphabatize the list. What problem I have when doing it is when I click sort button it always groups words like "A" and "The". I want it to ignore those words and focus on the word after "A" or "The" Create a helper column and add this formula to it =SUBSTITUTE(SUBSTITUTE(A20,"The ",""),"A ","") Then sort both columns by the helper column -- HTH Bob Phillips "Ronnie" <Ronnie@discussions.microsoft.com> wrote i...

DPM RC 2010 Agent Install on Windows Server 2008 R2
We are having trouble installing the DPM agent on a terminal server running Windows Server 2008 R2. If we install the agent manually, it installs fine and then gives this error when we try to attach it: 0x80004005 We removed all group policies from the server and turned off the firewall, but we still get this error. When I uninstalled the agent and tried to re-install through the console, this is what was in the error log: 12BC 0E94 04/06 14:07:08.824 03 agentcfg.cpp(475) [000000000076C200] NORMAL Cound not find configuration for DPMRA 12BC 0E94 04/06 14:07:08.824 03 run...

NDR on Public Folders when certain servers try to replicate
We have a multi site Exchange 2003/2000 server environment and I am noticing NDR messages similar to the following being sent to the postmaster: Undeliverable:Delivery Status Notification (Failure) Your message did not reach some or all of the intended recipients. Subject: Sent: 17/10/2005 15:34 The following recipient(s) could not be reached: Public Folder Store (Exch2k3svr) on 17/10/2005 15:35 You do not have permission to send to this recipient. For assistance, contact your system administrator. <smtp.domain.co.uk #5.7.1> If I click on ...

maling list
how do i create a mailing list, or transfer one from yahoo contacts "omtradelaw" <omtradelaw@discussions.microsoft.com> wrote in message news:1EA2BADE-2D73-498E-AC3A-A3A05DADDA1D@microsoft.com... > how do i create a mailing list, Contacts - New - Distribution List > or transfer one from yahoo contacts Get the Yahoo Intellisynch. ...

what causes the recently used file list option to be unavailable .
Tools / Options / Recently used file list is greyed out - How do I correct this ? John You don't say which version so try searching the knowledge base http://support.microsoft.com/default.aspx With a search string of MRU Disabled in Excel -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS "JohnPrice" <JohnPrice@discussions.microsoft.com> wrote in message news:ECA43906-EC33-4B92-8580-39923E449B9C@microsoft.com... > Tools / Options / Recently used file list is greyed out - How do I correct > this ? Hi! So...

How do I turn the pivot chart into a list with all cells filled?
I have the pivot chart and would like to copy and paste it so that all fields are filled Select the pivot table. Choose Edit>Copy Select the cell where you'd like to paste the copy Choose Edit>Paste Special Select Values, click OK There are instructions here for filling the blanks: http://www.contextures.com/xlDataEntry02.html gianna wrote: > I have the pivot chart and would like to copy and paste it so that all fields > are filled -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html ...

SPAM LISTING
Is there somewhere, on the internet, a list of SPAM sender that I can use to put filtering on my Exchange 2003 server? I have started to enter theme manualy but it's a long process!!!! Thanks! Jean-Seb I am using NoSPAMProxy. It has a cool monitor where I can blacklist something with one click. "John Smith" <john.smith@aol.com> schrieb im Newsbeitrag news:j5Whc.33230$CO3.1123537@news20.bellglobal.com... > Is there somewhere, on the internet, a list of SPAM sender that I can use to > put filtering on my Exchange 2003 server? I have started to enter theme > m...

Upgrading to Server 2008 R2 DC's
I run a one man IT shop and haven't done a major infrastructure change over before. We are looking at replacing and upgrading our small server infrastructure. I was hoping someone could give me some things to look out for. I basically want to replace all of our servers with new ones and migrate AD and Exchange up. Currently we have: 1x Server 2003 Standard SP2 that is Exchange Standard 2003 / DC / DNS (this has OWA facing internet) 1x Server 2003 Standard SP2 that is DC / DHCP 1x Server 2003 Standard SP2 that is a file server 1x off site hosted website I want to move to (i ...

Exchange Server Unavailable
Hi W2k AD Domain with Exchange 2000 in 2,000 users+ environment Problem 3 users setup in external workgroup, use Windows XP and Outlook 2003 to connect to exchange The first time they connect (from switching on /logging on) they ge "your microsoft exchange server is unavailable Then the 3 button "retry" "work offline" "cancel Clicking on retry always then connects up sucessfully and then can use outlook without problem Don't think it is dns or wins problem as can ping and map drives (\\...) both by name and IP Anyway have added enteries to hosts for excha...

backup same set of servers from 2 DPM 2007 servers
I am changing the DPM server 2007. However, I would like to take this opportunity to revise all protection groups so that I can restore bare-metal any server from a single lTO-4 tape if possible. During this "transitional period," I would like to leave the existing backup settings on the older DPM server to continue to run while adding jobs to the new DPM server. Looks like to me that I have to re-install the agent on all servers so that they can be recognized by the new DPM server. IS there a better way to do this if my plan is possible at all? Thanks Bill ...

PO not listed for Invoicing
We have a Drop-ship PO with status Released and Revision 0. We can view it under All Purchase Order Transaction window. But when we try to invoice it from eith View->Purchasing Lists window or POP window, it's not listed under the Vendor name. Any help is appreciated. Any chance already assigned to an Invoice Batch? -- Mick "ThongD" wrote: > We have a Drop-ship PO with status Released and Revision 0. We can view it > under All Purchase Order Transaction window. But when we try to invoice it > from eith View->Purchasing Lists window or POP window, it&...

Server 2003 Unbelievably Slow
Hi, First of all, I'd like to add that I'm not a professional in server systems. My problem is that my server is unbelievably slow. It is a new (3 months old) IBM xServer with quad core processor, 4 gb ram, 15k hdd, etc. I have sqlserver developer edition (db size is 4 gb) running for an erp software. I also have Kerio WinRoute Firewall on the server where I log all the internet activities of the users in the network. The Performance window (ctrl+alt+del) shows at a norma time app. 3-5%. However, even opening a folder from "My Computer" takes sometimes 10...

DPM 2010 Remote Agent Install (windows firewall settings)
I'm looking for the specific ports I need to unblock in order to push the agent from the console. All the documentation references point to firewall settings for the DPM server. I'm only interested in the windows firewall settings on the client (protected machine) necessary to push the agent. If I manually install on the client the installer opens the correct ports on the firewall for the agent to function so I'm not even concerned about those settings. I just need to be able to install/uninstall from the console and have been unable to do so unless I turn off the...