Getting Trusted Domain Computer Names

The -replace ‘\..*’, $domain snippet is in case here’s some AD funkiness that returns the FQDN from the external DNS record instead of internal. Some of my labs expose machines to other labs. Dammit, Jim, I’m a lab admin, not the DNS guru. function Get-ComputerNameFromTrustedDomain { if (!(Get-Command -Name Get-ADObject)) { Import-Module ServerManager; Add-WindowsFeature RSAT;…

0

Getting SRV Records with PowerShell

PowerShell leverages .NET, and .NET exposes the System.Net.Dns class, so all should be happy, no?  Evidently not if it comes to SRV records.  Someone asked me how to do it, and I said, “That’s easy.  I’ll get back to you in a few.” A few hours later, I realized it wasn’t so easy. Get-NslookupSrvRecord mail.microsoft.com…

1

Pinging a Hostname with Timeout

Well, that’s simple: $ping = New-Object System.Net.NetworkInformation.Ping;[bool]($ping.Send($computer, $pingTimeout).Status -ne ‘Success’); It gets more interesting when we need to verify that $computer is actually valid.  We can use [System.Net.DNS]::GetHostAddresses(), but that emits an error if the host doesn’t exist, which can be disconcerting if we’re trying to write something that looks pretty.  In this case, we’ll…

1