Resetting smartcard PIN via Powershell


we use smartcards (gemalto) store certs vpn authentication. 

we have requirement to provision multiple smart cards every month hire new staff. 

with internet , powershell knowledge got following code. below code read usernames text file process each user enroll cert them. problem prompts pin number each time user (person provisioning the cards). since default pin same new smartcards.

i hoping include default pin in script (so not prompt pin each time) , reset pin new value reading same text/cvs file. not able find on how pass or change pin via command line. 

code: 

function prov-smartcard ($user)
{
$pkcs10 = new-object -comobject x509enrollment.cx509certificaterequestpkcs10
$pkcs10.initializefromtemplatename(0x1,"smartcardenrollmenttemplate")
$pkcs10.encode()
$pkcs7 = new-object -comobject x509enrollment.cx509certificaterequestpkcs7
$pkcs7.initializefrominnerrequest($pkcs10)
$pkcs7.requestername = "et\$user"
$signer = new-object -comobject x509enrollment.csignercertificate
$cert = get-childitem cert:\currentuser\my | where-object {$_.extensions | where-object {$_.oid.value -eq "2.5.29.37" -and $_.enhancedkeyusages["1.3.6.1.4.1.311.20.2.1"]}}
$base64 = [convert]::tobase64string($cert.rawdata)
#$signer = new-object -comobject x509enrollment.csignercertificate
$signer.initialize(0,0,1,$base64)
$pkcs7.signercertificate = $signer
$request = new-object -comobject x509enrollment.cx509enrollment
$request.initializefromrequest($pkcs7)
$request.enroll()
read-host "gemalto $user has been provisioned sucessfully, please unplug , plug new one. press enter when ready"
}
import-csv ".\usernames.txt" -header "username" | % {$username = $_.username
prov-smartcard $username
}


hi,

hope below 2 article helpful you:

allow users change bitlocker pin without admin rights using sccm

http://blog.itminutes.net/?p=978

set-csclientpin

http://technet.microsoft.com/en-us/library/gg398929.aspx

regards,

yan li


cataleya li
technet community support



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Edit Group Policy

Hyper-V VM not reaching OS 'Logon' screen

DNS question...