Forum Discussion
Installing certificate
- Mar 01, 2023
Just put the PFX file and the install.cmd plus a uninstall.cmd in one directory and create a Win32 package.
You can use this as install.cmd
powershell.exe -executionpolicy bypass .\install.ps1
The install.ps1 file contains:
import-pfxcertificate -FilePath .\certificate.pfx -Exportable:$false -Password '123123' -CertStoreLocation Cert:\CurrentUser\My
the uninstall.cmd file contains the following:
powershell.exe -executionpolicy bypass .\uninstall.ps1
The uninstall.ps1 file contains the following:
Get-Childitem -Path Cert:CurrentUser\My | Where-Object Subject -Match 'yoursubjectname' | Remove-Item -Force:$true
Use a detection.ps1 containing:
If (Get-Childitem -Path Cert:CurrentUser\My | Where-Object Subject -Match 'yoursubjectname') {
Write-Host ("Certificate yoursubjectname found")
exit 0
}
else {
Write-Host ("Certificate yoursubjectname not found")
exit 1
}
Set the scope to User and test it 🙂 (Because I didn't 😛 )
Just put the PFX file and the install.cmd plus a uninstall.cmd in one directory and create a Win32 package.
You can use this as install.cmd
powershell.exe -executionpolicy bypass .\install.ps1
The install.ps1 file contains:
import-pfxcertificate -FilePath .\certificate.pfx -Exportable:$false -Password '123123' -CertStoreLocation Cert:\CurrentUser\My
the uninstall.cmd file contains the following:
powershell.exe -executionpolicy bypass .\uninstall.ps1
The uninstall.ps1 file contains the following:
Get-Childitem -Path Cert:CurrentUser\My | Where-Object Subject -Match 'yoursubjectname' | Remove-Item -Force:$true
Use a detection.ps1 containing:
If (Get-Childitem -Path Cert:CurrentUser\My | Where-Object Subject -Match 'yoursubjectname') {
Write-Host ("Certificate yoursubjectname found")
exit 0
}
else {
Write-Host ("Certificate yoursubjectname not found")
exit 1
}
Set the scope to User and test it 🙂 (Because I didn't 😛 )