title: Powershell script to scan for Expired SSL certificate for all server in OU not working
body: <p>I have used the DOMAIN\Administrator account is used for the credentials to run the below PowerShell script to scan for Expired SSL certificate:</p>
  
  <pre><code>$ScriptBlock = {
      Get-ChildItem Cert:\*\My -Recurse |
          Select-Object Subject, 
          DnsNameList, 
          NotAfter, 
          NotBefore, 
          Thumbprint, 
          Issuer,
          @{n = "SAN"; e = {Try {($_.Extensions | Where-Object {$_.Oid.Value -eq '2.5.29.17'}).Format(0)} Catch {} }},
          @{n = "IsValid"; e = {$today = Get-Date; If ( $_.NotBefore -lt $today -and $_.NotAfter -gt $today ) { $true } Else {$false} } } }
  
  $computers = Get-ADComputer -Filter {Enabled -eq $True -and OperatingSystem -like "*Server*"} -SearchBase "OU=Servers,OU=Production Site 1,DC=Domain,DC=com" | 
                  Where-Object {Test-Connection $_.Name -Count 1 -Quiet} | 
                  Select-Object -expandProperty DnsHostName | 
                  Export-Csv -Path C:\Logs\SSL.csv -NoTypeInformation
  
  $adCred = Get-Credential Invoke-Command -ComputerName $computers
  -ScriptBlock $ScriptBlock -Credential $adCred
  </code></pre>
  
  <p>But, then I got the error:</p>
  
  <blockquote>
    <p>[Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData]
    Connecting to remote server
    Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData failed
    with the following error message : WinRM cannot process the request.
    The following error occurred while using Kerberos authentication:
    Cannot find the computer
    Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData. Verify
    that the computer exists on the network and that the name provided is
    spelled correctly. For more information, see the
    about_Remote_Troubleshooting Help topic.
    + CategoryInfo : OpenError: (Microsoft.Power...FormatEntryData:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : NetworkPathNotFound,PSSessionStateBroken</p>
  </blockquote>
  
  <p>How to fix it so I can get the CSV result?</p>
  
  <p>The updated error code is now:</p>
  
  <blockquote>
    <p>Invoke-Command : Cannot validate argument on parameter 'ComputerName'.
    The argument is null or empty. Provide an argument that is not null or
    empty, and then try the command again. At line:19 char:30
    + Invoke-Command -ComputerName $computers -ScriptBlock $ScriptBlock -Cr ...
    +                              ~~~~~~~~~~
        + CategoryInfo          : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand</p>
  </blockquote>