I was wondering if there is a way to stipulate which version of Powershell is in开发者_如何转开发itialised (32bit\64bit) on a 64bit windows 2008 server using c# and the the system.automation namespace?
The reason for this is I have created a ps1 script that uses a com object which will only work in a 32bit Powershell environment.
I am not aware of a way to specify 32bit\64bit during runspace creation but may be wrong. Any thoughts or suggestions?
Thanks
Changing your application's configuration from "Any CPU"/"x64" to "x86" is definitely the simplest way to make sure the Powershell script runs in 32-bit. You can check it with a script with these contents:
if ([System.IntPtr]::Size -eq 8) {'64-bit'} else {'32-bit'}
Configuring the Runspace
to be 32-bit running in a 64-bit application may be possible, but it may also be more trouble than it's worth.
精彩评论