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!
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
Usually you will provide a domain or local admin account for that purpose.
$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
}
(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?
ASKER