I’ve seen a nice tweet a few weeks ago about how to get the client’s current Active Directory Site.
I cannot remember who tweeted it. Kudos to him/her, it’s very handy.
Of course, there are other (ugly) ways to get it, using gpresult.exe
gpresult /R /scope computer| Select-String -Pattern "Site\sName" | Out-String | ConvertFrom-Csv -Delimiter ":" -Header "Property","Value"
… or using nltest.exe
((nltest /DSGETSITE) -split "`n")
The .Net way is now definetly my favorite 😀
I wondered how far this System.DirectoryServices.ActiveDirectory.ActiveDirectorySite .Net class is available?
I could have find the answer using the following MSDN page:
…but my first attempt was the hard way
I remembered that I could easily get the Dll a cmdlet is loaded from with the Get-Command cmdlet:
Get-Command -Name Get-Command | fl Dll
How can I get the same info for a .Net class?
[System.Reflection.Assembly]::GetAssembly( [System.DirectoryServices.ActiveDirectory.ActiveDirectorySite] ) | fl Location
So, the answer is that the System.DirectoryServices.ActiveDirectory.ActiveDirectorySite .Net class is available as of .Net version 2.0 on any (domain joined) client. Cool, isn’t it? 😎