Link to home
Start Free TrialLog in
Avatar of fireburn11
fireburn11

asked on

powershell script to look for DNS suffix for this connection

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!
ASKER CERTIFIED SOLUTION
Avatar of X Layer
X Layer
Flag of Slovenia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fireburn11
fireburn11

ASKER

I am getting access denied error when executing the script.
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.
How did you solve the "access denied" issue?