adamdriscoll / poshprotools

PowerShell Pro Tools and Universal Dashboard
https://ironmansoftware.com/
104 stars 24 forks source link

Issue with unsigned scripts when packaging as an executable #3

Open nickalleyne opened 7 years ago

nickalleyne commented 7 years ago

Hi Adam,

I have been testing packaging a form as an executable, and for the most part it has gone well, but I have run into one issue with packaging.

When I run a certain script as a powershell script, I am able to execute it fine on a computer that has execution policy set to "Restricted", yet if I convert it to an executable, and I try to run the same script, it errors out at a certain point. It connects to my exchange server and imports the cmdlets, then runs enable-mailbox, code is below. The strange part is that it runs when a powershell script, but not when an executable.

$exch = @{
        ConfigurationName = 'Microsoft.Exchange'
        ConnectionUri = 'http://server.domain/PowerShell/'
        Authentication = 'Kerberos'
    }
    $ExchangeSession = New-PSSession  @exch
    Import-PSSession $ExchangeSession

Enable-Mailbox -Identity $UserName -Database $ExchangeDatabase

This is very possibly not a PoshProTools issue, in which case, sorry about wasting your time, but one potential option would be add a way to sign the scripts which could help solve this issue (which I guess would change this from a bug to a feature request).

adamdriscoll commented 7 years ago

@nickalleyne Thanks for the feedback. Let me do some testing and get back to you.

adamdriscoll commented 7 years ago

I'm going to mark this as an enhancement. I will need to introduce a way to sign scripts as you mentioned. It would also be possible to override the execution policy for the executable but I know that won't work in all environments.