We have a certificate server from which users are able to download their certificate (User Template) from this URL: http://localhost/certsrv.
I now want to create a script which will do the following:
- Delete the existing certificate from Personal Certificate store.
- Install the new certificate in Personal certificate store.
I already made the script, and it is able to delete the certificate but installation is not happening because the command is not supporting in Windows 7.
Here is my code:
# User Details
$dom = $env:userdomain
$usr = $env:username
$fulname = ([adsi]"WinNT://$dom/$usr,user").fullname
#get certificate & Remove the certificate
$Cert = Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.Subject -match "$fulname"} | Remove-Item
#Install new certificate
Get-Certificate -Template User -DnsName mydomain.com -CertStoreLocation cert:\CurrentUser\My