Share this post: This is part of an ongoing blog series by Adam Gordon. Adam will show you how to use each PowerShell command each week. Adam will be covering Test-FileCatalog this week.
When should you use Test-FileCatalog
Test-FileCatalog verifies the authenticity of files by comparing file hashes from a catalog file (.cat), with actual files on disk.
It will return ValidationFailed if it finds any mismatches.
All this information can be retrieved by users using the -Detailed parameter.
It also displays signing status of catalog in Signature property which is equivalent to calling Get-AuthenticodeSignature cmdlet on the catalog file.
You can also skip any file during validation using the -FilesToSkip parameter.
NOTE: This cmdlet can only be used on Windows.
What version of PowerShell should I use for this blog?
Get the PowerShell Version for your machine
$PSVersionTable
This command displays the PowerShell version information for your machine.
How do you use Test-FileCatalog
Create and validate a file catalogue
Line #1: New-FileCatalog -Path $PSHOME\Modules\Microsoft.PowerShell.Utility -CatalogFilePath \temp\Microsoft.PowerShell.Utility.cat -CatalogVersion 2.0
Line #2: Test-FileCatalog -CatalogFilePath \temp\Microsoft.PowerShell.Utility.cat -Path “$PSHome\Modules\Microsoft.PowerShell.Utility\”
Line 1 uses the New-FileCatalog cmdlet for creating a new file catalogue. It uses the –Path parameter in order to specify a folder, or array of files that should validate against the catalog file. The -CatalogFilePath parameter specifies a path to a catalog (.cat) that contains validation hashes.
The -CatalogVersion parameter accepts either 1.0 or 2.0 values to specify the catalog version. Avoid 1.0 as it uses an insecure SHA-1 algorithm. 2.0 uses the secure SHA256 algorithm. 1.0 is supported on Windows 7 and Server 2008R2.
Line 2 uses the Test-FileCatalog cmdlet and the -CatalogFilePath parameters to specify a path (.cat) to a catalog file that contains validation hashes. It uses the –Path parameter in order to specify a folder (or array) of files that should validate against the catalog file.
Validate a file catalogue with detailed output.
Test-FileCatalog -CatalogFilePath \temp\Microsoft.PowerShell.Utility.cat -Path “$PSHome\Modules\Microsoft.PowerShell.Utility\” -Detailed
The Test-FileCatalog cmdlet uses a -CatalogFilePath parameter. This specifies a path to a catalog (.cat) that contains validation hashes. It uses the –Path parameter for specifying a folder or array that should be validated against a catalog file. The -Detailed parameter returns a more detailed CatalogInformation object. It contains the files that were tested, their expected/actual hashes and, if applicable, an authenticode signature of the catalog.
Learn the command last week: New-PSDrive.
Do you need PowerShell training? ITProTV offers PowerShell online IT training courses.