script comand for "com port" staus needed

rated by 0 users
Not Answered This post has 0 verified answers | 1 Reply | 1 Follower

Top 500 Contributor
20 Posts
Hecktor posted on 07-21-2011 9:27 AM

 I need to verify if "com ports" are disabled or enabled on windows servers, so i run this command in my script

"get-itemproperty -path hklm:hardware\devicemap\serialcomm" and it shows me this

PSChildName : serialcomm PSDrive : HKLM PSProvider : Microsoft.PowerShell.Core\Registry \??\Root#PORTS#0000#{86e0d1e0-8089-11d0-9ce4-08003e301f73} : COM4 \??\Root#PORTS#0001#{86e0d1e0-8089-11d0-9ce4-08003e301f73} : COM5 Winachsf0 : COM3
If  the "com ports" have been disabled in device manger then the output should not show any com ports listed or paths

So if i change the command to say this

get-itemproperty -path hklm:hardware\devicemap\serialcomm | Select-Object -Property 'PSChildName','Winachsf0'

I get this @{PSChildName=serialcomm; Winachsf0=COM3}

and if i do -Property for the other paths


I would get the results for COM4 and COM5

But is there a way to just get the "com" info. So that if none are found then they will have been disable but if any show then they are active and it list's which ones?

Anyone how to do this?

Thank you 

All Replies

Top 25 Contributor
296 Posts
Microsoft MVP
Top Contributor

I can't help I'm afraid as I don't have access to a machine with COM ports  Sad

But check

Get-WmiObject -Class Win32_SerialPort



and see if they return anything you could use 

Page 1 of 1 (2 items) | RSS
Copyright 2012 All rights reserved.