I'm trying to get [poshrunner.exe] to be able to run a script in a PowerShell version 2.0 environment on a machine where PowerShell version 3.0 is installed. PowerShell.exe supports this, although it seems that distinct support for PowerShell 1.0 is dubious.
I'm running Windows 8. I have two versions of System.Management.Automation.dll in my GAC:
- System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (loaded by
powershell.exe -version 3.0
) - System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (loaded by
powershell.exe -version 1.0
andpowershell.exe -version 2.0
)
As far as I can tell I have no publisher policy assembly for System.Management.Automation.dll
C:\Windows\assembly\GAC_MSIL>dir C:\Windows\assembly\GAC_MSIL\policy*
Volume in drive C has no label.
Volume Serial Number is 0207-A8AA
Directory of C:\Windows\assembly\GAC_MSIL
11/16/2012 11:49 PM <DIR> Policy.12.0.Microsoft.Office.Interop.Access.Dao
12/13/2012 11:49 PM <DIR> policy.2.1.Microsoft.Web.PlatformInstaller
12/13/2012 11:49 PM <DIR> policy.3.0.Microsoft.Web.PlatformInstaller
10/29/2012 03:33 PM <DIR> policy.3.5.System.Data.SqlServerCe
10/29/2012 03:33 PM <DIR> policy.3.5.System.Data.SqlServerCe.Entity
0 File(s) 0 bytes
5 Dir(s) 51,204,710,400 bytes free
C:\Windows\assembly\GAC_MSIL>
However, doing an AppDomain.CurrentDomain.Load("System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
is loading version 3 of the assembly. Assembly.Load() has the same results.
Before calling assembly:
[]
After Calling Assembly:
[]
That code happens to be running in a secondary app domain, so I'm willing and able to much about with AppDomain settings. How do I force System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 to laod conditionally at runtime.