Script doesn't work when compiled to .exe

Ask your Windows 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.
User avatar
jvierra
Posts: 13793
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Mon Jan 08, 2018 12:12 pm

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

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

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

Post by Chris.Ediger » Mon Jan 08, 2018 1:54 pm

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: )

User avatar
jvierra
Posts: 13793
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Mon Jan 08, 2018 2:32 pm

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: 25
Joined: Tue Oct 24, 2017 9:33 am

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

Post by Chris.Ediger » Tue Jan 09, 2018 12:40 pm

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!!??

User avatar
jvierra
Posts: 13793
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » 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.

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

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

Post by Chris.Ediger » Tue Jan 09, 2018 1:08 pm

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!!

User avatar
jvierra
Posts: 13793
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Tue Jan 09, 2018 1:13 pm

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

Locked