Stepped away from SCCM for a while but used to leverage VBscripts all the time to query various things and drop them into WMI. Now that I'm back in the SCCM world I'd like to do this again but with PowerShell. Having a devil of a time. I found Sherry and Matthew's script here:
http://www.sccm-tools.com/tools/vbscript/vbscript-certificates.html I wanted to convert it to Powershell but I'm striking out on the initial array. This is the code in VBScript: Store.Open CAPICOM_LOCAL_MACHINE_STORE, "MY" ,CAPICOM_STORE_OPEN_READ_ONLY Set Certificates = Store.Certificates If Certificates.Count >0 Then For Each Certificate in Certificates g=g+1 strSubjectName(g) = Certificate.SubjectName strIssuerName(g) = Certificate.IssuerName strValidFrom(g) = Certificate.ValidFromDate strValidTo(g) = Certificate.ValidToDate strDaysToExpire(g) = DateDiff("d",now(),Certificate.ValidToDate) This is how I'm trying to do it in Powershell but I keep getting an error about "Cannot index into a null array". Any help? Sorry for being a poor scripter :) $Certificates = Get-ChildItem -Path cert:\LocalMachine\My If ($Certificates.Count -gt 0) {ForEach ($Certificate in $Certificates) { $g++ $strSubjectName[$g] = $Certificate.SubjectName $strIssuerName[$g] = $Certificate.IssuerName $strValidFrom[$g] = $Certificate.NotBefore $strValidTo[$g] = $Certificate.NotAfter $strDaysToExpire[$g] = New-TimeSpan -End ([DateTime]$Certificate.NotAfter) $strDaysToExpire[$g] = $($strDaysToExpire.days) } } Script probably has other issues too but one step at a time Thanks Casey

