something exciting

Some information about the exciting thing

Table of contents generated with markdown-toc


Check connectivity of a system

This function pings and opens a connection to the default RDP port to verify connectivity, futhermore it will check if a DNS entry exists and whether there is a computeraccount

Name: Test-ComputerName
Author: Jaap Brasser
Version: 1.0
DateUpdated: 2013-08-23


.PARAMETER ComputerName
The computer to which connectivity will be checked


Will perform the ping, RDP, DNS and AD checks for the local machine

Test-ComputerName -ComputerName server01,server02

Will perform the ping, RDP, DNS and AD checks for server01 and server02
Function Test-ComputerName {
    param (
        [string[]]$ComputerName = $env:COMPUTERNAME

    begin {
        $SelectHash = @{
            'Property' = @('Name', 'ADObject', 'DNSEntry', 'PingResponse', 'RDPConnection')

    process {
        foreach ($CurrentComputer in $ComputerName) {
            # Create new Hash
            $HashProps = @{
                'Name'          = $CurrentComputer
                'ADObject'      = $false
                'DNSEntry'      = $false
                'RDPConnection' = $false
                'PingResponse'  = $false

            # Perform Checks
            switch ($true) {
                { ([adsisearcher]"samaccountname=$CurrentComputer`$").findone() } { $HashProps.ADObject = $true }
                { $(try { [system.net.dns]::gethostentry($CurrentComputer) } catch {}) } { $HashProps.DNSEntry = $true }
                { $(try { $socket = New-Object Net.Sockets.TcpClient($CurrentComputer, 3389); if ($socket.Connected) { $true }; $socket.Close() } catch {}) } { $HashProps.RDPConnection = $true }
                { Test-Connection -ComputerName $CurrentComputer -Quiet -Count 1 } { $HashProps.PingResponse = $true }
                Default {}

            # Output object
            New-Object -TypeName 'PSCustomObject' -Property $HashProps | Select-Object @SelectHash

    end {

Back to Top


Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.

Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.


Back to Top