X-Git-Url: https://us-delaporte.pagekite.me/gitweb/dotfiles.git/blobdiff_plain/7e0e193ba73dafeb8437720b779f5c9ed86223f2..bd9f3d19bc86ce9be64c505edca894a2dab92f06:/psmodules/sign.psm1?ds=sidebyside diff --git a/psmodules/sign.psm1 b/psmodules/sign.psm1 index a5667de..17820f5 100644 --- a/psmodules/sign.psm1 +++ b/psmodules/sign.psm1 @@ -3,6 +3,31 @@ Commands to maintain a local code singing cert. +This is a hack to solve allowing PowerShell to trust a PowerShell profile hosted on a UNC path, without allowing 'Unrestricted' execution policy. + +I created this because it annoys me that my mandatory UNC path profile counts as a remote script, and I'm too pedantic to un-restrict all remote scripts just to allow my profile to load. + +.NOTES + +Works fine under PowerShell Core 6 with ExecutionPolicy RemoteSigned. PowerShell 7 + +.EXAMPLE + +Set-ExecutionPolicy RemoteSigned + +Import-Module c:\src\dotfiles\psmodules\sign.psm1 + +# Make a cert + +> New-CodeSignCert +# Install it - you will be promted whether to trust it. + +> Install-CodeSignCert + +# Sign your UNC path PowerShell profile +> Invoke-CodeSign $profile + + #> $certName = "Local Code Sign Cert" $codeSigning = "" @@ -32,7 +57,7 @@ function Invoke-CodeSign { Set-AuthenticodeSignature -FilePath $Path -Certificate $cert } -Invoke-CodeSignProfile { +function Invoke-CodeSignProfile { Invoke-CodeSign -Path $profile }