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
Different results in Form .ps1 vs .exe
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.
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.
Re: Different results in Form .ps1 vs .exe
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.
It sounds like you are getting an undetected error or null from some missing function.
Re: Different results in Form .ps1 vs .exe
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
.ps1 was run via an elevated PS session
PS> . 'export.ps1'
.exe was run, right-click, Run As Adminstrator