0

I have a script that show the dll version for zip file Now I have a CAB file but it doesn't work for him Here is my script: How can I change it to CAB

$path = "C:\Temp\test\New folder\cab\ForTesting"
$tempFolder = Join-Path ([IO.Path]::GetTempPath()) (New-GUID).ToString('n')
$compressedfiles = Get-ChildItem -path $path\* -Include "*.zip"

foreach ($file in $zips) {
    try {
        $zip = [System.IO.Compression.ZipFile]::ExtractToDirectory($file, $tempFolder)
        $dlls = Get-ChildItem $tempFolder -Include "*.dll","*.exe" -Recurse
        foreach($dll in $dlls) {
 
       if ((($dll.VersionInfo.FileVersion) -eq "1.0.0.0") -or (($dll.VersionInfo.FileVersion) -eq "0.0.0.0"))
        {
            Write-host "The version of $($dll.Name) is: $($dll.VersionInfo.FileVersion) for: $($file.Name)" -ForegroundColor yellow
        }
        else {write-host "Dll $($dll.Name) version is: $($dll.VersionInfo.FileVersion)" -ForegroundColor Green}
        }
    }
    catch {
        Write-Warning $_.Exception.Message
        continue
    }
    finally {
        Remove-Item $tempFolder -Force -Recurse
    }    
}
Bandit
  • 399
  • 3
  • 10
  • 3
    Does this answer your question? [Get file version in PowerShell](https://stackoverflow.com/questions/30686/get-file-version-in-powershell), which says to use `($dll.VersionInfo.FileVersion) -eq "1.0.0.0"` – Luuk Mar 05 '22 at 12:52
  • Don't know...I expected to an idea why my script is wrong... – Bandit Mar 05 '22 at 12:54
  • 2
    [VersionInfp](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.fileversioninfo?view=net-6.0) is an object, and you should use `VersionInfo.FileVersion`, which is a property of it. – Luuk Mar 05 '22 at 12:57
  • The premise of your question has changed, I would recommend you to ask a new question with this information since this one has been closed for being a duplicate. – Santiago Squarzon Mar 06 '22 at 17:06

0 Answers0