Implement PowerShell PSProvider *in* PowerShell Implement PowerShell PSProvider *in* PowerShell powershell powershell

Implement PowerShell PSProvider *in* PowerShell


I would strongly recommend looking at the stuff Oisin wrote, suspect for people like you, who can grab their head around it, that could be very good reference on how-to. Or maybe what to avoid? ;)You can find it on codeplex: http://psprovider.codeplex.com/


I know it's been some time since you asked the question, but I've been searching for that same answer myself. As it happens, re-reading the Samples in msdn finally got me my answer, and given the frustration quotient I thought I'd share:

The assembly containing the provider needs to be imported using Import-Module (not merely the module containing the add-type declaration). This can be done using two ways:

Option 1:Use the parameter of Add-Type that builds the runtime assembly as a .dll file and import the file.

Option 2:Import the runtime assembly from memory. This is how I did that with the standard msdn samples:

[appdomain]::CurrentDomain.GetAssemblies() | Where {$_.ExportedTypes -ne $null} | Where {($_.ExportedTypes | Select -ExpandProperty "Name") -contains "AccessDBProvider"} | Import-Module

Replace the Provider name in the where filter with your own.

Cheers,Fred