PowerShell: Retrieve site location of computer object

This is a nice find that I am cataloging from Shay Levy.

You can get the site location of a computer if you run this PS script on the computer itself.

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

 

It’s effectively the same as using NLTEST.

nltest /dsgetsite

 

I had intended to use it with Compliance Settings but the compliance rules limitations made it a impractical. Still going to be useful for other stuff. If you want remote options, read more about it at the original post: #PSTip Get the AD site name of a computer.

Comments