Script doesn't work when compiled to .exe

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
jvierra
Posts: 14444
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Script doesn't work when compiled to .exe

Post by jvierra »

Be sure you are also using STA mode in both the designer and the build.

User avatar
Chris.Ediger
Posts: 42
Joined: Tue Oct 24, 2017 9:33 am

Re: Script doesn't work when compiled to .exe

Post by Chris.Ediger »

The exact error is at the beginning of this post. If there was a problem with our AD servers why do the scripts work when I run them from within PSS (click the green triangle :mrgreen: )

jvierra
Posts: 14444
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Script doesn't work when compiled to .exe

Post by jvierra »

The error you are referring to is this:
"Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services running."

I suspect your Firewall is blocking the EXE from access but there could be other external causes. By default PSS opens firewall ports for outbound connections when it is installed.

User avatar
Chris.Ediger
Posts: 42
Joined: Tue Oct 24, 2017 9:33 am

Re: Script doesn't work when compiled to .exe

Post by Chris.Ediger »

Ok, here's a new twist. If I log in with my domain admin credentials the script runs just fine. What is it about compiling it into an exe!!??

jvierra
Posts: 14444
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Script doesn't work when compiled to .exe

Post by jvierra »

Again - There is likely an issue with your network or AD setup. There is no way for us to help you sort this out. You can now see that the script works but fails when you change the account. For some reason your system will only allow admins to connect.

The other possibility is that the EXE needs to update the system settings to run. (see the images I posted). Only an Admin can do this.

User avatar
Chris.Ediger
Posts: 42
Joined: Tue Oct 24, 2017 9:33 am

Re: Script doesn't work when compiled to .exe

Post by Chris.Ediger »

jvierra wrote:
Tue Jan 09, 2018 1:05 pm
Again - There is likely an issue with your network or AD setup. There is no way for us to help you sort this out. You can now see that the script works but fails when you change the account. For some reason your system will only allow admins to connect.

The other possibility is that the EXE needs to update the system settings to run. (see the images I posted). Only an Admin can do this.
But why does it work when it's not compiled!!?? I don't do my work logged in as domain admin. It works fine from within PSS!!

jvierra
Posts: 14444
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Script doesn't work when compiled to .exe

Post by jvierra »

Unfortunately I cannot reproduce your environment. The EXE works for me.

Locked