0

I know there are a lot of commands to get the Windows version through PowerShell, but I would like to instead get the OS Name (so it can be Linux, for example) of a Remote Computer (in my Domain). How I can do that in PowerShell?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
  • Does this answer your question? [Determine the OS version, Linux and Windows from Powershell](https://stackoverflow.com/questions/44703646/determine-the-os-version-linux-and-windows-from-powershell) – Scepticalist Sep 01 '21 at 13:54
  • @Scepticalist No. It only shows the OS version on my local computer, not on a Remote Computer. – Nicolò Vitelli Sep 01 '21 at 14:03
  • How will you connect to a remote non-Windows machine? What if the remote machine doesn't have a computer account in the domain? (Your question is more complicated than you think it is.) – Bill_Stewart Sep 01 '21 at 14:31
  • Then use PSRemoting/Invoke it on the remote computer - you can use WMI but it will not retrieve Linux – Scepticalist Sep 01 '21 at 14:32
  • @Bill_Stewart Every remote machine does have an account in the domain, that's for sure – Nicolò Vitelli Sep 01 '21 at 14:34
  • If you are sure about that, and the join is correct, then the SMB client on the system is supposed to update the computer account in AD with the operating system type. – Bill_Stewart Sep 01 '21 at 14:35

3 Answers3

0
$ttl = Test-Connection $Computer -BufferSize 16 -Count 1 -ea 0 | select -exp ResponseTimeToLive

if($ttl -lt 65){$system = "Linux"} elseif($ttl -gt 126){$system = "Windows"}
  • I have had problems with TTL in PS 7 as an fyi. I tried to use the TTL and it is not always 100% – dcaz Sep 01 '21 at 15:12
-1

#quick and dirty

Get-WmiObject -Class win32_operatingsystem -Property * -ComputerName anyhost | Format-List Caption,Name,Version

Mr. S.
  • 17
  • 1
-1

#quick and dirty for Active Directory

Get-ADComputer -Filter * -Properties OperatingSystem   | select Name,OperatingSystem
Mr. S.
  • 17
  • 1