Windows Terminal Server Host Name

Tech Worm | Sun, 24 Sep 2017 at 11:45 hours | Replies : 1 | Points : 50

Category : Windows Server 2003


one Windows 2003 Terminal Server in our environment. We have almost 2500 servers. Can you please help me to get the Terminal Server host name?


This Question is already solved Click To See The Answer


HI,

you can use below powershell cmd to find that

 

 

Import-Module activedirectory
$search = New-Object DirectoryServices.DirectorySearcher([ADSI]"")
$search.filter = "(servicePrincipalName=*)"
$results = $search.Findall()

foreach ($result in $results){
$srvname = ($result.Properties.serviceprincipalname | ?{$_ -like "TERMSRV/*"})[0].replace("TERMSRV/","")
Get-ADComputer $srvname -Properties operatingsystem | ?{$_.operatingsystem -like "*2003*"}
}