Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check for DNS record using PowerShell 2.0

Tags:

powershell

What could be the best way to resolve a computer name apart from using:

[System.Net.DNS]::GetHostByName('MachineName').HostName

I dont want to import any specific DNS Modules.

like image 728
Rajiv Avatar asked Dec 21 '22 07:12

Rajiv


1 Answers

You can try the GetHostEntry method:

[Net.DNS]::GetHostEntry("MachineName")

Another way would be to ping it using Test-Connection cmdlet, see this tip

like image 62
Shay Levy Avatar answered Jan 15 '23 04:01

Shay Levy