Functions/Get-ComputerADSite.ps1

function Get-ComputerADSite {
    <#
    .Parameter ComputerName
        Specifies the computer or computers
 
    .Notes
        AUTHOR: Skyler Hart
        CREATED: 02/09/2018 00:11:18
        LASTEDIT: 02/09/2018 00:11:18
        KEYWORDS:
 
    .LINK
        https://wanderingstag.github.io
    #>

    [CmdletBinding()]
    Param (
        [Parameter(
            Mandatory=$false,
            Position=0,
            ValueFromPipeline = $true
        )]
        [Alias('Host','Name','Computer','CN')]
        [string[]]$ComputerName = "$env:COMPUTERNAME"
    )

    Begin {
        $info = @()
    }
    Process {
        $info = foreach ($comp in $ComputerName) {
            $site = nltest /server:$comp /dsgetsite 2>$null
            if($LASTEXITCODE -eq 0){$st = $site[0]}
            else {$st = "NA"}
            [PSCustomObject]@{
                ComputerName = $comp
                Site = $st
            }#new object
        }
    }
    End {
        $info
    }
}