Go Premium for a chance to win a PS4. Enter to Win


PowerShell Script to check file version across the network

Published on
3,519 Points
1 Endorsement
Last Modified:
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.

Our office runs an application that is constantly being updated.  Unfortunately the program is not easy to update via Group Policy (GPO), so instead of walking to each computer to check if it needs an upgrade or if it is running multiple versions, I wrote this script to do the legwork for me.  To modify this script simply change <ProgramVersions> <ProgramFolder> and <ProgramFile> to suit your needs.  You will also need to modify the  $LogFile variable to a path that exists on your own system.  It can take some time to run, especially if you have a lot of systems to check.  The end result is a log file that tells you where to find what you are looking for so you can work more efficiently.

# I like a tidy workspace


# Errors happen, just move on.  Comment this out if you want to see what broke.

$ErrorActionPreference = "silentlycontinue"

# Make a log,  

$LogTime = Get-Date -Format "MM-dd-yyyy_hh.mm.ss"

$LogFile= 'C:\work\<ProgramVersions>.'+$logtime+'.txt'

$logtime | Out-File $LogFile

# Need this to discover what computers are on the network

Import-Module ActiveDirectory

$computer = (Get-ADComputer -Filter 'ObjectClass -eq "Computer"' | Select -Expand DNSHostName)

$drawline=  "-----------------------------------------------------------------------------------------------------------------------"

# Get that list of computers and do something with it.

foreach ($computer1 in $computer) {

# Define what we are looking for




# The program we are looking for may have multiple instances.  Here's another possible location.




# Go find what we are looking for and log it.

if ((Get-ChildItem -Recurse $FilePath) -eq $null){



else {

$drawline | Tee-Object $LogFile -Append

$computer1 | Tee-Object $LogFile -Append

Get-ChildItem  -Recurse $FilePath | foreach-object { "{0,-80}`t{1}" -f $_.FullName,  [System.Diagnostics.FileVersionInfo]::GetVersionInfo($_).FileVersion } |  Tee-Object $LogFile -Append

Get-ChildItem -Recurse  $FilePath2 | foreach-object { "{0,-80}`t{1}" -f $_.FullName,  [System.Diagnostics.FileVersionInfo]::GetVersionInfo($_).FileVersion }   | Tee-Object $LogFile -Append

$drawline| Tee-Object $LogFile -Append




The way this works is pretty simple.  We first ask Active Directory for a list of computers (this is why it's important to keep active directory tidy folks).  Then the script goes around an asks every computer in that list to search it's file system to see if they have this program installed.  In my case, I know that the program I am looking for is in multiple locations, so ask again for the other location(s).  Then give me a report on what you found.

It is possible to modify this script to find the installed program file in the registry, even multiple instances, but then it will not find those programs that do not make registry entries.  Also I wanted this script to be flexible enough that I could look for any file, not just programs.

I try to keep my code as simple and readable as possible.  There is a difference between code and cryptogrophy.  If you make suggestions to improve this code, please document it.  It really helps, even the experienced.

This is a reprint of my original article on my blog xpertnotes.net.  Click here to see the original article.


Expert Comment

by:Senior IT System Engineer
Does the user will notice any performance issue when the scanning is running ?

Author Comment

by:Frank McCourry
Performance degradation is relative only to the number of paths and at what level you enter that path.  It is the equivalent of performing a non-indexed search on the users computer.  If you keep the search path narrow, the user will probably not even notice.  If you start at the root, I guarantee that your phone will ring.  

This script was designed to find a specific file in specific locations, thereby limiting the amount of hard drive activity it causes on the end users computer.  I run this once a month or so and have had no complaints.

Featured Post

Lessons on Wi-Fi & Recommendations on KRACK

Simplicity and security can be a difficult  balance for any business to tackle. Join us on December 6th for a look at your company's biggest security gap. We will also address the most recent attack, "KRACK" and provide recommendations on how to secure your Wi-Fi network today!

Join & Write a Comment

Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month