< Back

Get-ADSIComputerSite

Mon Jan 13, 2020 7:55 pm

NAME Get-ADSIComputerSite



SYNOPSIS

Function to retrieve the AD Site of a Computer





SYNTAX

Get-ADSIComputerSite [[-ComputerName] <String[]>] [<CommonParameters>]





DESCRIPTION

Function to retrieve the AD Site of a Computer



This function does not rely on the .NET Framework to retrieve the information

http://www.pinvoke.net/default.aspx/net ... etsitename



There is .NET method to get this information but only works on the local machine.

[System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite()





PARAMETERS

-ComputerName <String[]>

Specifies the computer name(s) that you want to know the site.



Required? false

Position? 1

Default value $env:computername

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

System.Management.Automation.PSCustomObject





NOTES





Francois-Xavier Cat

lazywinadmin.com

@lazywinadm

github.com/lazywinadmin/FXDemo



Thanks to the Reddit folks for their help!





-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-ADSIComputerName -ComputerName TestServer01



This will retrieve the Site of the Computer TestServer01









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-ADSIComputerName -ComputerName TestServer01,TestServer02



This will retrieve the Site of the Computers TestServer01 and TestServer02











RELATED LINKS