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 😛 )
- Mar 01, 2023
You should choose to Use a custom detection script for that as a Rules Format under Detection rules 😉 The subject name is the certificate's name after importing it. You can check it on the system where you installed the certificate by running Get-Childitem -Path Cert:CurrentUser\My
- oryxwayMar 01, 2023Iron ContributorI tried this on the machine where this PFX is installed, unfortunately nothing came up
Get-Childitem -Path Cert:CurrentUser\My
I tried to run this on my office destktop and I did get couple but mostly related to Adobe and nothing related to this certificate which is installed under Personal\Certificate. The certificate is installed.
Any other suggestions thoughts?- Mar 01, 2023Is it in your computer certificate store?