Home > other >  How to get the complete Digital signature info's of files containing in multiple sub folders
How to get the complete Digital signature info's of files containing in multiple sub folders

Time:12-10

I am absolute beginner in coding, My question is how can i retrieve complete details of Digital Certificate of files containing in multiple sub folders(export to csv). With little help from google, i found below powershell code which suffice this for a single file.

get-childitem C:\Windows\notepad.exe | Get-AuthenticodeSignature  |Format-List

I am having 300 files (exe/DLLS) in multiple sub folders. What i what

  • Fetch the details for all the files including files in sub folders.
  • Export the details to csv. csv Format

    Then you could try the following script:

    EDIT: Removed the System.Array as per Santiago.

    # Make an array containing all FilePaths by importing the .csv file to a variable
    $Files = (Import-Csv C:\Path\To\Import.csv).FilePath
    
    # Run the script for each $File in the $Files array
    $AllFilesExport = ForEach($File in $Files) {
        
        # Get the information you want about the file
        $FileInfo = Get-ChildItem $File | Get-AuthenticodeSignature
        
        # Specify the Column name (left) and what data it should have in it (right)
        [pscustomobject]@{
            'SignerCertificate:Subject' = $FileInfo.SignerCertificate.Subject
            'SignerCertificate: Issuer' = $FileInfo.SignerCertificate.Issuer
            'SignerCertificate: Serial Number' = $FileInfo.SignerCertificate.SerialNumber
            'SignerCertificate: Not Before' = $FileInfo.SignerCertificate.NotBefore
            'SignerCertificate: Not After' = $FileInfo.SignerCertificate.NotAfter
            'SignerCertificate: Thumbprint' = $FileInfo.SignerCertificate.Thumbprint
            'TimeStamperCertificate: Subject' = $FileInfo.TimeStamperCertificate.Subject
            'TimeStamperCertificate: Issuer' = $FileInfo.TimeStamperCertificate.Issuer
            'TimeStamperCertificate: Serial Number' = $FileInfo.TimeStamperCertificate.SerialNumber
            'TimeStamperCertificate: Not Before' = $FileInfo.TimeStamperCertificate.NotBefore
            'TimeStamperCertificate: Not After' = $FileInfo.TimeStamperCertificate.NotAfter
            'TimeStamperCertificate: Thumbprint' = $FileInfo.TimeStamperCertificate.Thumbprint
            'Status' = $FileInfo.Status
            'StatusMessage' = $FileInfo.StatusMessage
            'Path' = $FileInfo.Path
        }
    }
    
    # Export all of the file information from the AllFileExport array into an export .csv file
    $AllFilesExport | Export-Csv -NoTypeInformation C:\Path\To\Export.csv
    
  • Related