0

We have recently acquired a small firm having 1500 servers on which our team doesn't has access as of now although they are in domain. We need to find out how many servers are running Windows 2k3 and how many are Windows 2k8. I know the RDP screen of both of these versions are different , for example: if we RDP a Win2k3 machine, it gives a warning notice first and once we click Ok, it takes us to the credentials screen , but in case of Win2k8, it directly takes us to Crendentials which is a proof of the OS on the server. Doing this manually for 1500 servers is a time consuming task. Can we implement this RDP screen logic using a script to find out the Windows OS version.

I can imagine an Algorithm something like that:

  1. Enter server name.
  2. Invoke mstsc for that server
  3. Verify if the dialogue box is a direct prompt for credentials or not?
  4. If so, print Windows 2k8, else 2k3/2k.

If this logic successful on one server, I can use it in a foreach loop for all servers and export in in Excel.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Brite Roy
  • 425
  • 3
  • 9
  • 28
  • They use a different version of the RDP protocol, so it would probably be easier to detect that difference. I'd be surprised if there isn't an existing network scanner (e.g., Nessus?) that could do this for you,. – Harry Johnston Aug 14 '15 at 23:02
  • Thanks for your kind reply. But as I already its a firm and we are in the transition , there are no accesses and resources as of now in the environment. Apart from network scanner, can you suggest any other way? Is it possible to implement the RDP logic (I mentioned in description) into powershell script? – Brite Roy Aug 17 '15 at 03:23

1 Answers1

0

With 1500 servers I'm going to assume that you have an Active Directory in place. In that case you should be able to simply run a query against AD to retrieve the desired information:

Import-Module ActiveDirectory

$server = 'somehostname'
$dc = '...'  # domain controller of trusted domain

$fltr = "OperatingSystem -like '*server*'"

Get-ADComputer -Filter $fltr -Property OperatingSystem -Server $dc |
  Where-Object { $_.Enabled } |
  Select-Object Name, OperatingSystem |
  Sort-Object OperatingSystem, Name

Pipe the result into Export-Csv to create a CSV file that you can import into Excel.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • Thanks for your reply Ansgar. I'm not aware of the Get-ADComputer module (its in powershell I suppose) but I guess this needs to be run after logging on to the DC, right? If this is the case, then as already informed we currently don't have access to any of those servers. As far as my brain goes, verifying the OS version through the type of RDP screen is the only temporary workaround, just need to implement in a vbs or PS script. Any suggestions? – Brite Roy Aug 14 '15 at 21:43
  • You don't need to be on a domain controller, just need to have the AD PowerShell cmdlets installed somewhere. Can be a workstation or a non-DC server. – Benjamin Hubbard Aug 14 '15 at 21:49
  • It's part of the `ActiveDirectory` module. You can run it on any server that has the `RSAT-AD-PowerShell` feature (*"Active Directory module for Windows PowerShell"*) or on any client that has the [RSAT](http://www.microsoft.com/en-us/download/details.aspx?id=39296) installed. – Ansgar Wiechers Aug 14 '15 at 21:51
  • The servers of the new firm are not in the domain of our company , only a trust relationship has been build up so that they are only currently able to ping from our domain. The method which you mentioned suggests that it will find the OS version of the server registered in our domain (which is not in this case). Although I've not tried your method, but I'll do it also as the last hope and let you know results. Meanwhile can you please identify any other way out? May be any way to implement RDP logic into powershell script? – Brite Roy Aug 17 '15 at 03:42
  • @BriteRoy `Get-ADComputer -Server` allows you to run queries against other servers (for instance the DC of a different domain). Screen scraping RDP logon screens to determine the operating system of the remote host is a *terrible* approach, and my only advice on it is: DON'T. – Ansgar Wiechers Aug 17 '15 at 06:49
  • Unfortunately, I'm not able to install RSAT tool from any of the packages in the below link, tried both x86 and x64 http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=2852] I'm trying to install on our test 2k8 server. The install fails with error , not supported architecture. I'll try it my desktop which is also in domain but with insufficient priviledges. – Brite Roy Aug 17 '15 at 21:59
  • I know , scraping RDP logon is a terrible approach , but we don't have any option as of now. The same was suggested by our engineering team as well since (although terrible and time consuming) it will yield correct result. – Brite Roy Aug 17 '15 at 22:05
  • @BriteRoy You can't install those packages on a server. On Server 2008 R2 or newer the feature is already present and can be enabled in Server Manager. Otherwise you need to install the RSAT package on a *client*. Server versions prior to 2008 R2 don't support the feature. – Ansgar Wiechers Aug 17 '15 at 22:30
  • Sorry for the late reply, din't get time to execute this on a sever. Finally did it today a win2k8 test server which it asked to install .net components and IIS before installing the RSAT feature. I did the same, then tried to add the feature and was prompted for the reboot. After reboot got error as , could not install RSAT on local server, something like that. It was very disappointing for me. I dint get time to troubleshoot the issue, will do it later, till then anyluck with screen scrapping? – Brite Roy Aug 22 '15 at 17:06
  • Yes, I do ,but not sure on what part of the reply did you write that. Will troubleshoot RSAT on server once I get time. – Brite Roy Aug 23 '15 at 20:18
  • On the entire response. a) The RSAT package is for **clients**. You can't install it on servers. b) On Windows Server 2008 **R2** and newer the AD PowerShell module already comes with the operating system and can be enabled in the *Features* section of Server Manager. The module is **not available** for Windows Server 2008 (first edition) and earlier. c) My answer to screen sraping is **no**. I already told you all of this before. – Ansgar Wiechers Aug 23 '15 at 22:39
  • Sorry for the late response. So after analyzing whole environment and taking help our from AD team came to know that the server objects of the new firm are not in the AD of our firm so no point of RSAT anymore since we don't have access to AD of their environment. I know its quite complicated case but so it is. Hence, we don't have any option right now than to manually check for all servers or write a screen scapping code which I don't think anyone can assist with. Thanks a lot everyone for your kind responses. Thread can be closed as unsolved. – Brite Roy Sep 06 '15 at 13:19
  • You said a trust was established between your domain and theirs. If that's the case you should be able to query objects from their AD as well as yours. Your AD team should know that and also how to do it. – Ansgar Wiechers Sep 06 '15 at 13:26