In my opinion, given the stated requirements, there's no need for a for-loop, and you could use a more realistic property too.
If you take a look at the value list for ProductType
under Win32_OperatingSystem
, there are only three, Work Station (1
), Domain Controller (2
), and Server (3
). As a Domain Controller is technically a Server too, all you need to check for is a ProductType
of 1
, which for you, will be a PC
.
"%SystemRoot%\System32\wbem\WMIC.exe" OS Where ProductType="1" Get Name 2> NUL | "%SystemRoot%\System32\find.exe" "|" 1> NUL && (Echo PC) || Echo Server