CodeSigning/Invoke-SignFile.ps1
function Invoke-SignFile { Param( [Parameter(Mandatory=$true)] [string] $FileName, [Parameter(Mandatory=$true)] [securestring] $pfxFile, [Parameter(Mandatory=$true)] [securestring] $pfxPassword ) $ContainerName = (Get-EnvironmentKeyValue -KeyName 'name') # Copy file to container path $ContainerPath = (Join-Path (Join-Path "C:\ProgramData\NavContainerHelper\Extensions" $containerName) "my") $ContainerPath = (Join-Path $ContainerPath (Split-Path $FileName -Leaf)) Copy-Item $FileName $ContainerPath -Force | Out-Null #Sign $unsecurepfxFile = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pfxFile))) Sign-NavContainerApp -containerName $containerName -appFile $ContainerPath -pfxFile $unsecurePfxFile -pfxPassword $pfxPassword # Copy file back Copy-Item $ContainerPath $FileName -Force | Out-Null Remove-Item $ContainerPath -Force | Out-Null } Export-ModuleMember -Function Invoke-SignFile |