Solved

powershell script to look for DNS suffix for this connection

Posted on 2012-04-04
4
1,940 Views
Last Modified: 2012-05-08
Hi All,

I need a powershell script to read in a text file that contains computer name and look for DNS suffix for this connection, then print out the computer name and the DNS suffix for this connection.


Please help!
0
Comment
Question by:fireburn11
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
X_layer earned 500 total points
ID: 37808580
Lets say that you have computers listed in computers.txt file. Then you can try something like this:
Get-Content .\computers.txt | Foreach-Object {Get-Wmiobject Win32_NetworkAdapterConfiguration -ComputerName $_ -Property * -Filter "DNSHostName = '$_'" | select DNSHostName,Description,DNSDomainSuffixSearchOrder}

Open in new window

0
 

Author Comment

by:fireburn11
ID: 37812193
I am getting access denied error when executing the script.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 37821152
To retrieve the original info of each computer, you need a single, valid user for all computers, and run the script under that account. Or provide a PSCredential object with each WMI command, like
$creds = New-Object System.Management.Automation.PSCredential ("MyUser", 
    (ConvertTo-SecureString -AsPlainText -Force "MyPwd") )
gc .\computers.txt | % {
  Get-Wmiobject Win32_NetworkAdapterConfiguration -ComputerName $_ -PsCredentials $creds -Property * -Filter "DNSHostName = '$_'" |
  select DNSHostName, Description, DNSDomainSuffixSearchOrder
}

Open in new window

(if you want to use a single account different from your one the script is running in).
Usually you will provide a domain or local admin account for that purpose.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 37889622
How did you solve the "access denied" issue?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
A brief introduction to what I consider to be the best editor for PowerShell.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question