< Back
Get-ADComputerSite
Post
NAME Get-ADComputerSite
SYNOPSIS
Gets the AD Site for the specified computer.
SYNTAX
Get-ADComputerSite [[-ComputerName] <String>] [-AsADSite] [<CommonParameters>]
DESCRIPTION
Calls DsGetSiteName() and retrieves the current Active Directory site for the specified ComputerName. The cmdlet
will throw an exception if it cannot
contact the specified computer or if the computer is not part of a site.
PARAMETERS
-ComputerName <String>
The computer to query the AD site name for. Leave this blank to query the local machine.
Required? false
Position? 1
Default value [System.String]::Empty
Accept pipeline input? false
Accept wildcard characters? false
-AsADSite [<SwitchParameter>]
This parameter specifies that the site name returned to DsGetSiteName is supplied to Get-ADReplicationSite and
returns a Microsoft.ActiveDirectory.Management.ADReplicationSite instead of a string.
Required? false
Position? named
Default value False
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
System.String
OUTPUTS
System.String, Microsoft.ActiveDirectory.Management.ADReplicationSite
NOTES
AUTHOR: Michael Haken
LAST UPDATE: 8/7/2017
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$SiteName = Get-ADComputerSite
Gets the AD site for the local computer. The return value would be Default-First-Site-Name if the computer is in
that AD site.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>$SiteName = Get-ADComputerSite -ComputerName myserver01
Gets the AD site for the remote computer myserver01.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>[Microsoft.ActiveDirectory.Management.ADReplicationSite]$ReplSite = Get-ADComputerSite -AsADSite
Gets the AD site the local computer is a member of as an Microsoft.ActiveDirectory.Management.ADReplicationSite
object.
RELATED LINKS
SYNOPSIS
Gets the AD Site for the specified computer.
SYNTAX
Get-ADComputerSite [[-ComputerName] <String>] [-AsADSite] [<CommonParameters>]
DESCRIPTION
Calls DsGetSiteName() and retrieves the current Active Directory site for the specified ComputerName. The cmdlet
will throw an exception if it cannot
contact the specified computer or if the computer is not part of a site.
PARAMETERS
-ComputerName <String>
The computer to query the AD site name for. Leave this blank to query the local machine.
Required? false
Position? 1
Default value [System.String]::Empty
Accept pipeline input? false
Accept wildcard characters? false
-AsADSite [<SwitchParameter>]
This parameter specifies that the site name returned to DsGetSiteName is supplied to Get-ADReplicationSite and
returns a Microsoft.ActiveDirectory.Management.ADReplicationSite instead of a string.
Required? false
Position? named
Default value False
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
System.String
OUTPUTS
System.String, Microsoft.ActiveDirectory.Management.ADReplicationSite
NOTES
AUTHOR: Michael Haken
LAST UPDATE: 8/7/2017
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$SiteName = Get-ADComputerSite
Gets the AD site for the local computer. The return value would be Default-First-Site-Name if the computer is in
that AD site.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>$SiteName = Get-ADComputerSite -ComputerName myserver01
Gets the AD site for the remote computer myserver01.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>[Microsoft.ActiveDirectory.Management.ADReplicationSite]$ReplSite = Get-ADComputerSite -AsADSite
Gets the AD site the local computer is a member of as an Microsoft.ActiveDirectory.Management.ADReplicationSite
object.
RELATED LINKS