This is a on-prem TFS question. Yesterday I put a certificate in place to handle signing ClickOnce deployments. However, it fails to apply the certificate. They guy who wrote these release scripts before me, the former TFS administrator, was a PowerShell guru. I am not a PowerShell guru. However, I can muddle my way into trying to figure out what is going on, up to a point. The errors occur in the Release, not in the build. The first error that appears is, “You cannot call a method on a null-valued expression”. I believe I’ve found the line where that error occurs, from the PowerShell++ script he uses. It is here:
> $cert = ls cert:\ -Recurse -CodeSigningCert | ? {$_.Verify()} | Select -First 1
I’ve broken this line down into its parts. Ignoring the assignment to the variable $cert, this part of the PowerShell script works: $cert = ls cert:\ -Recurse -CodeSigningCert. However, the rest of the line, ? {$_.Verify()} | Select -First 1 results in assigning a null to $cert. This same script has worked fine, for two years, with no problems. Why has importing a new certificate into the TFS build server made this assignment fail?
no, I cannot elaborate on the Verify() function. I didn’t write the PowerShell script. The former TFS administrator did. He was a PS guru - I am, at best, just a casual user of PS. Like you, I’m convinced that Verify() function is at the root of my problem. The first part of the PS script ls cert:\ -Recurse -CodeSigningCert does produce results. 4 lines of results. What really bothers me is that why should this PS script, which has worked for years, suddenly stop working? What conditions are now in place that the Verify() method no longer likes, but did as recently as last week?
Wasn’t the code signing certificate going to expire? Perhaps Verify checks the validity? Has the code signing certificate already expired? Also, is any of those 4 results your new code signing certificate?
Rouke, The short answer to your question is I don’t know if the new cert is in the list or not. When I run the ls command it gives me 4 lines, but the Subject line is truncated. All of them have the same text, as far as it allows me to see. I know there’s some command I can issue to a PS script to have it display the results in a window, but I don’t remember that parameter I need to provide
That does give me the full text, thank you. I’ve run it, but it doesn’t show me the expiration dates. So I got back into MMC, added the Certificates add-in, then ran it as the user the former guy used. I see the new cert there, with an expiration date of June 28, 2023