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.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 45
Last visit: Tue May 09, 2023 8:35 pm

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 45
Last visit: Tue May 09, 2023 8:35 pm

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 45
Last visit: Tue May 09, 2023 8:35 pm

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

Post by Chris_Ediger »

jvierra wrote: Tue Jan 09, 2018 12: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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

Unfortunately I cannot reproduce your environment. The EXE works for me.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked