Prerequisites: Create a file that has the list of machines netbios names, and create an empty systems.txt file on your root.
<#
Reference URL: http://blogs.technet.com/b/heyscriptingguy/archive/2010/03/11/hey-scripting-guy-march-11-2010.aspx
This file will read Machinelist from a file, try to get their DNS information,
and append that output to a txt file.
You can use the above mentioned URL for more information and exaples of the Try\Catch\Finally
#>
ForEach ($entry in (Get-Content c:\scripts\machinelist2.txt)) {
Try {
[net.dns]::GetHostEntry($entry).Hostname | Out-File -FilePath c:\systems.txt -Append
} Catch {
$entry | Out-File -FilePath c:\scripts\Machine_WithFQDN.txt -Append
}
}
Joe P.
No comments:
Post a Comment