your home for end-user virtualization!

Comparing a list of files and their versions across multiple servers using Windows Powershell

I ran into a situation where I needed to make sure all of my Citrix PVS servers were patched accordingly. To do that, I needed to examine the version of various files located in the Program File’s directory. To do this, I used Windows Powershell to examine the file version information and report on it.

I was able to import a list of computers (one per line), and list of files (one per line) to examine, then walk through the list for each server.

$servers = get-content c:\comp.txt
$items = get-content c:\binarys.txt

foreach ($server in $servers)
        foreach ($item in $items)
                $fileinfo = (Get-ChildItem "\\$server\c$\Program Files\Citrix\Provisioning Services\$item").VersionInfo
                       "" | select @{Name="Hostname"; Expression={$server}},
                @{Name="Filename"; Expression={$item}},
                @{Name="Fileversion"; Expression={$fileinfo.fileversion}}