I was recently writing a C# dll to the invoked in PowerShell. As I tested the PowerShell script, I found that the dll was being locked and any re-compiles from Visual Studio were being rejected.
I used the following code to resolve the problem:
$bytesCommon = [System.IO.File]::ReadAllBytes("c:\folder\driver.dll")
$loadResultCommon = [System.Reflection.Assembly]::Load($bytesCommon)