github twitter linkedin email
Renaming Perfmon Collector Set Files With Powershell
Aug 29, 2018
One minute read

Why that filename?

Perfmon lets you prefix and/or append data collector set filenames with the current date so you don’t need to do anything if you’re working with multiple days of files.

However, if you forget … (which I sometimes do), you can find yourself with dozens of files named DataCollector01.blg. Not very useful if you want to analyse them together. Having them in their own folder for each day adds a complexity to it also.

Let’s rename

Whilst it’s not the most arduous task to move and rename them individually, I’m a DBA and time is premium.

First thing is to rename all files, giving them a unique filename. I’m using a guid to differentiate the files.

Get-ChildItem -File -Recurse | ForEach-Object { Rename-Item -Path $_.PSPath -NewName $_.Name.replace("DataCollector01","$([guid]::NewGuid().ToString()+$_.extension)") }

Now each file is uniquely named we can move them into a single directory.

Get-ChildItem -Path 'C:\Temp\Perfmon\DirectoryOfUnzippedPermonFiles' -Recurse -File | Move-Item -Destination 'C:\Temp\Perfmon'

It’s a lot easier to work with now all the files are in a single directory.

This was just a quick reference entry for me, but if you find it useful I’d love to know.


Back to posts