-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfoDeviceConnection.ps1
34 lines (29 loc) · 1.09 KB
/
infoDeviceConnection.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Leggi il nome del dispositivo dal file config.ini
$ConfigPath = ".\config.ini"
$DeviceName = (Get-Content -Path $ConfigPath | Select-String -Pattern "DeviceName").ToString().Split("=")[1].Trim()
# Controlla se il dispositivo Bluetooth è connesso
$BTDevice = Get-PnpDevice -FriendlyName "*$($DeviceName)*"
if ($BTDevice) {
$Connected = $false
foreach ($Device in $BTDevice) {
$ConnectionProperty = Get-PnpDeviceProperty -InstanceId $Device.InstanceId -KeyName '{83DA6326-97A6-4088-9453-A1923F573B29} 15' |
Where-Object { $_.Type -ne 'Empty' } |
Select-Object -ExpandProperty Data
if ($ConnectionProperty -eq $true) {
$Connected = $true
break
}
}
if ($Connected) {
Write-Output "Connected"
# Qui puoi fare quello che vuoi fare se il dispositivo è connesso
}
else {
Write-Output "Disconnected"
}
}
else {
Write-Output "Bluetooth device not found."
}
# Salva l'output in un file
Out-File -FilePath "tempPSOutput_Connected.txt" -InputObject $Connected