49 lines
1.5 KiB

function ParameterDefinitions {
param(
[Parameter()][string] $subject = 'punkshell local',
[Parameter(Mandatory)][string] $friendlyname = 'test code signing',
[Parameter(ValueFromRemainingArguments)] $opts
)
}
function psmain {
[CmdletBinding()]
param()
dynamicparam { GetDynamicParamDictionary ParameterDefinitions }
process {
#called once with $PSBoundParameters dictionary
#can be used to validate arguments, or set a simpler variable name for access
switch ($PSBoundParameters.keys) {
'subject' {
Set-Variable -Name $_ -Value $PSBoundParameters."$_"
}
#...
}
}
end {
Write-Host "Certificate subject is: $subject"
$params = @{
Subject = $subject
Type = 'CodeSigningCert'
KeySpec = 'Signature'
KeyUsage = 'DigitalSignature'
FriendlyName = $friendlyname
CertStoreLocation = 'Cert:\LocalMachine\My'
NotAfter = (Get-Date).AddMonths(60)
}
Write-Host "please wait..."
#$cert = New-SelfSignedCertificate @params
#Write-Host "cert: $cert"
#echo "Exporting to file for import to certstore.."
#Export-Certificate -FilePath exported_localmachine_new-cert.cer -Cert $cert
#Import-Certificate -Filepath exported_localmachine_new-cert.cer -CertstoreLocation Cert:\LocalMachine\My
#echo "Finished importing.."
}
}
psmain @args