Different results in Form .ps1 vs .exe

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
Post Reply
User avatar
harringg
Posts: 11
Last visit: Fri Jul 23, 2021 6:51 am

Different results in Form .ps1 vs .exe

Post by harringg »

I've got a small WinForm that checks if a Get-WindowsCapability item is installed (requires Admin rights to check).

I've saved .PSF as Export.ps1 and Export.exe (x64 and x86 both)

When dot-sourcing the .ps1 file, it works as expected, when running the .exe file, it reports that the RSAT item isn't installed. I've got an if-else and that part works, because it thinks its not installed.

Wondering what is different in the .exe
2021-07-15_20-11-48.png
2021-07-15_20-11-48.png (38.12 KiB) Viewed 567 times

jvierra
Posts: 14866
Last visit: Wed Jul 21, 2021 2:13 am
Answers: 12
Has voted: 3 times
Been upvoted: 10 times

Re: Different results in Form .ps1 vs .exe

Post by jvierra »

Sorry but images won't tell us anything. Why dotsource anything? It is only useful to load referenced functions as global functions.

It sounds like you are getting an undetected error or null from some missing function.

User avatar
harringg
Posts: 11
Last visit: Fri Jul 23, 2021 6:51 am

Re: Different results in Form .ps1 vs .exe

Post by harringg »

I just meant they are the same .psf, one export to file (.ps1) and one Build (.exe) I may have used the term dot-source incorrectly.

.ps1 was run via an elevated PS session
PS> . 'export.ps1'
.exe was run, right-click, Run As Adminstrator

jvierra
Posts: 14866
Last visit: Wed Jul 21, 2021 2:13 am
Answers: 12
Has voted: 3 times
Been upvoted: 10 times

Re: Different results in Form .ps1 vs .exe

Post by jvierra »

WStill not enough information to know what you are doing.

Post Reply