32Feet.Net in Powershell

Welcome Forums General PowerShell Q&A 32Feet.Net in Powershell

This topic contains 0 replies, has 1 voice, and was last updated by  Dizzydbd60 3 weeks, 2 days ago.

  • Author
  • #173425

    Topics: 1
    Replies: 0
    Points: -4
    Rank: Member

    Hello! First of all, I am not a coder and second I struggled with this for 2 days before asking for help 🙂

    I am trying to programmatically pair 2 Bluetooth devices with PowerShell using the 32Feet.Net library (InTheHand.Net.Bluetooth). One is PIN-based and it is straight forward, but the 2nd one is using SSP.

    I found this piece of code that it is supposed to do achieve this (I have bolded the important part):

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using InTheHand.Net.Bluetooth;
    using System.Threading;
    namespace BT
        class BluetoothAutoSSP
            public static void Main()
                BluetoothAutoSSP c = new BluetoothAutoSSP();
                EventHandler handler = new         EventHandler(c.handleRequests);
                BluetoothWin32Authentication authenticator = new BluetoothWin32Authentication(handler);
                while (true)
            public void handleRequests(Object thing, BluetoothWin32AuthenticationEventArgs args)
                args.Confirm = true;

    Basically, a handler that will be called by BluetoothWin32Authentication and will set the Confirm parameter of BluetoothWin32AuthenticationEventArgs to true.
    Below is the latest version (after hundreds of tries and changes) but the Powershell terminal crashes with "PowerShell has stopped working" so something must be wrong:

    Add-Type -Path "InTheHand.Net.Personal.dll"
    $cli = New-Object InTheHand.Net.Sockets.BluetoothClient
    $devs = $cli.DiscoverDevices()
    $dev = $devs | ? { $_.DeviceName -eq "XXXX" }
    $handleRequests = {
    param([object]$sender, [InTheHand.Net.Bluetooth.BluetoothWin32AuthenticationEventArgs]$sourceArgs)
    $sourceArgs.Confirm = $true
    $auth = [InTheHand.Net.Bluetooth.BluetoothWin32Authentication]::New($handleRequests)

You must be logged in to reply to this topic.