From a list of server host names I am trying to get a list of the operating systems installed.I am using the following command in powershell;
Get-Content "servers.txt" | Get-ADComputer -Properties Name, OperatingSystem
| Select Name, OperatingSystem > ServerOperatingSystems.txt
This works to an extent and populates the text file with servers it is able to locate. For the servers it's unable to locate or obtain the operating system I would like this to be marked with "Not found". At the moment, there is no mention of these servers in the output text file. Essentially something like this;
Server 1 Windows Server 2012
Server 2 Windows Server 2012
Server 3 "Not found"
Thanks in advance.