Untitled Document
View RSS Feed

ShipRush Ecommerce and Feature Discussion

Powershell: Profiles, x86, Plugins, and x64

Rating: 5 votes, 4.40 average.
Name:  powershell-logo-image-thumb44.png
Views: 788
Size:  8.0 KB

I spent some time on this, and now I will share! There can be some frustrating parts of Powershell.

Let's say you are on a web server, and it is x64. You have a powershell script, and a custom powershell addin from your developer.

You notice odd behavior, that the addin does not load consistently. In my situation, I found that my scheduled task did not work properly. On one system, the script worked correctly from a command line, but on the server it did not work properly. On the server, it worked fine when I ran it from FAR Manager command line, but not when from a cmd.exe prompt.

What can this mean?

It can mean that the addin is an x86 assembly. In this case, it will only work if your powershell environment on the x64 server is running in 32 bit (aka x86) mode.

How to tell?

Name:  powershell-options.png
Views: 493
Size:  25.2 KB

First, see if your addin runs when you use the 32bit option for Powershell. This may tell you a lot.

If that is the problem, you can recompile the addin as a universal assembly, or you can simply run the 32 bit Powershell. This can be done from your scheduled task:

%SystemRoot%\sysWOW64\WindowsPowerShell\v1.0\power shell.exe .\yourscript.ps1

Profiles

Did you notice that your Powershell profiles are magically duplicated? I noticed the size of my profile.ps1 file in this location was 0 bytes:

C:\WINDOWS\system32\WindowsPowerShell\v1.0\

But over here, it was the expected size:

C:\WINDOWS\SysWOW64\windowspowershell\v1.0\

This is because the 0 byte file just looks like a file. Actually it is a symbolic link to the real file.


I hope this helps someone. It took me a long time to figure out that the assembly I was given was a 32 bit assembly!

Updated 05-05-2011 at 05:35 PM by Vladislaw Poniedelnik

Tags: addin, powershell, x86 Add / Edit Tags
Categories
Software Development & Technology

Comments