Search code examples
.netpowershellactive-directory

Are there any simple ways of calling the "AD Object Picker" in Powershell?


I'm writing a Powershell 5.0 script with a form in which the user can optionally select an AD object.

Upon clicking a button, I need to present them with the "AD Object Picker" dialog (I'm not sure if that's what it's called), eg:

enter image description here

...and store their selected object in a variable.

I'm not sure how to properly call this dialog in Powershell as I don't even know what it's officially named (which makes researching it difficult), let alone if there's a .NET control or wrapper for it.

Can you show me a method to call up this dialog (and what the darned thing is actually called)?


Solution

  • That dialog is built into Windows and is called the IDsObjectPicker interface. So whatever solution is used needs to be able to call native Windows code. This isn't easy from PowerShell. Microsoft's example is in C++.

    There is some discussion about using it from PowerShell here, with some example PowerShell code that may or may not work.

    There is also a link to this project that has a wrapper DLL for all the native code that you can use from PowerShell (examples there too), but one of the comments said that it didn't work in newer PowerShell versions.