We would like to do a statistic, over all notebooks, to check if they have a SIM card inserted. Is there a way to check this? I played already around with netsh, but maybe is there an easy query, just for checking if a SIM is inserted.
Asked
Active
Viewed 1,581 times
-1
-
Hi, welcome to StackOverflow. This site is not meant to provide free code for you, rather for specific coding problems. I hope you solve your issue! – CompanyDroneFromSector7G Mar 05 '20 at 16:29
1 Answers
0
How does this do, I am not that good at this, but maybe:
$comPortNumber = Get-WMIObject win32_potsmodem | where-object {$_.DeviceID -like "*05C6*"} | foreach {$_.AttachedTo}
# 05C6 is the Vendor ID for Qualcomm, AttachedTo returns the Com port number
if (!$comPortNumber) { Return "No Gobi Card Detected!" }
else {
$port = New-Object System.IO.Ports.SerialPort
$port.PortName = $comPortNumber
$port.BaudRate = "9600"
$port.Parity = "None"
$port.DataBits = 8
$port.StopBits = 1
$port.ReadTimeout = 9000 # 9 seconds
$port.DtrEnable = "true"
$port.open() #opens serial connection
Start-Sleep 2 # wait 2 seconds until device is ready
$port.Write("AT$")
$port.Write("QCGSN `r") #writes your content to the serial connection
try
{
while($myinput = $port.ReadLine())
{
$myinput
}
}
catch [TimeoutException]
{
# Put handling code here
}
finally
{
# Put the clean up code here
}
$port.Close() #closes serial connection
}

Theo
- 57,719
- 8
- 24
- 41

FireyChicken
- 74
- 6
-
i dont get any return from the first line command "Get-WMIObject win32_potsmodem" (with SIM inserted ofc.) – ITRevSup Mar 05 '20 at 16:29