I need to read all file version for each dll and exe files that located inside a zip. This is what I have so far. I was able to hold a dll but there is no .fileversion for the object
$vips = Get-ChildItem -path C:\_Projects\temp\Patch_1296247.vip
$checkfiles= "*.dll"
#C:\_Projects\temp\Patch_1296247.vip
foreach ($file in $vips) {
try {
$zip = [System.IO.Compression.ZipFile]::Open($file, "Read")
}
catch {
Write-Warning $_.Exception.Message
continue
}
$dlls = $zip.Entries.Where({ $_.Name -like "*.dll" })
foreach($dll in $dlls) {
$dll.FileVersion
$zip.Dispose()}}
The dll have only those properties
If I run this line I can get the dll version.Maybe because it is not in a ZIP? How can I add it to my script?
(Get-Item C:\_Projects\temp\Patch_1296247\ADWalk_4.0.0.101\JobAdWalk\AdWalk\a.Client.ServicesProvider.dll).VersionInfo.FileVersion
Its ok to write the if like that? I want to print all dlls with 1.0.0.0 and 0.0.0.0 I get that all dlls is ok although all of them with 1.0.0.0 or 0.0.0.0 (($dll.VersionInfo) -eq "1.0.0.0") --> False ?!?!
Maybe it should be like this?
if ((($dll.VersionInfo) -eq "1.0.0.0") -or (($dll.VersionInfo) -eq"0.0.0.0")
Or should be:
if (($dll.VersionInfo) -eq "1.0.0.0")
{}
elseif (($dll.VersionInfo) -eq "0.0.0.0")
{}
foreach ($file in $vips) {
try {
$zip = [System.IO.Compression.ZipFile]::ExtractToDirectory($file, $tempFolder)
$dlls = Get-ChildItem $tempFolder -Include "*.dll","*.exe" -Recurse
foreach($dll in $dlls) {
#$dll.VersionInfo
if (($dll.VersionInfo) -eq "1.0.0.0" -or "0.0.0.0")
{
write-host
Write-host "The version of $($dll.Name) is wrong!!!" -ForegroundColor Red
}
else {write-host "All dlls are ok"}
}
}