I am trying to write a Power Shell script which will check the connection status of paired Bluetooth devices in a certain interval (15 sec) and if found the device is out of range then will lock the users system. In the following code I am not able to figure out how to list all the paired device.
$ListAllDevice = "Get the list of all paired Bluetooth Device"
$DeviceStatus = $ListAllDevice | Get-ItemProperty
$DeviceDetection = ($DeviceStatus).DeviceState
ForEach($IndDetection in $DeviceDetection)
{
If($IndDetection -eq 1)
{
Write-Host "device detected."
}
Else
{
rundll32.exe user32.dll,LockWorkStation
}
}
}
While in other approach I also tried with the following code, but here Nodestatus doesn’t change enen if the connection out of range.
(Get-Device | Where-Object {$_.Name -like '*Lenovo*'}).NodeStatus
Any idea how this can be done ?