This page is retired and no longer updated. Project documentation and download links are moved to their new home: PowerShell PKI Module.

Start-PsFCIV

Synopsis

Checks files integrity. This command is an enhanced version of Microsoft's File Checksum Integreity Verifier (FCIV).

Syntax

Start-PsFCIV [-Path] <DirectoryInfo> [-XML] <String> [[-Include] <String>] [[-Exclude] <String[]>] [-Action <String> {Rename | Delete} ] [-Show <String[]> {Bad | Locked | Missed | New | Ok | Unknown | All} ] [-HashAlgorithm <String[]> {MD5 | SHA1 | SHA256 | SHA384 | SHA512} ] [-Recurse] [-Rebuild] [-Quiet] [-NoStatistic] [<CommonParameters>]

Start-PsFCIV [-Path] <DirectoryInfo> [[-Include] <String>] [[-Exclude] <String[]>] [-Action <String> {Rename | Delete} ] [-Show <String[]> {Bad | Locked | Missed | New | Ok | Unknown | All} ] [-HashAlgorithm <String[]> {MD5 | SHA1 | SHA256 | SHA384 | SHA512} ] [-Recurse] [-Rebuild] [-Quiet] [-NoStatistic] [-Online] [<CommonParameters>]

Description

This command calculates hashes for each file and stores this information in an XML database. Once the database is created, the command can check file integrity against database.

This command supports both, PsFCIV and native FCIV database formats.

Parameters

-Path <DirectoryInfo>

Specifies the path to folder that contains files to be verified by the script.

Required? True
Position? 0
Default value
Accept pipeline input? false
Accept wildcard characters? False

-XML <String>

Specifies the path to the XML database that stores information about files. If database does not exist, the script will create it. The path can be absolute or relative. If the path is relative, the database must be placed in the root folder of Path parameter.

Required? True
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? False

-Include <String>

Specifies the file to check. If specified, only this file will be checked during execution.

Required? False
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? False

-Exclude <String[]>

Speicifes the file or files to exclude from check. The XML database is excluded by default.

Required? False
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? False

-Action <String>

Specifies the action for files with inconsistent length, modification date/time or hash mismatch. Possible values are 'Rename' or 'Delete'. If 'Rename' is specified, the script will add .BAD extension to a file name.

Required? False
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? False

-Show <String[]>

Specifies file group that will be shown based on some criteria in graphic Out-GridView window. Possible values are: New, Ok, Bad, Missed, Unknown and Locked. You can combine these values. Additionally, selected file groups are stored in a global variable: $global:stats and can be used for afterward processing.

Note: this parameter has no effect when 'NoStatistic' switch parameter is specified.

Required? False
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? False

-HashAlgorithm <String[]>

Specifies the hash algorithm to use. Can be one (or combination) of the following algorithms: MD5, SHA1, SHA256, SHA384, SHA512.

Algorithms can be combined only when you create a new XML file. In this case each file is hashed by using every algorithm specified. If no algorithm is specified, SHA1 is used as the default algorithm.

If more than one algorithm is specified during file checking, then only the first algorithm is used. If no algorithm is specified then the strongest algorithm is used for a particular file. For example, an entry in XML database contains hashes for SHA1 and SHA256, another entry has only MD5 hash. In this case SHA256 is used for the first file and MD5 for another file. The strongest algorithm is determined automatically.

Required? False
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? False

-Recurse <SwitchParameter>

Specifies whether the script should check files in subfolders.

Required? False
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? False

-Rebuild <SwitchParameter>

Recreates the XML database without checking files. If files listed in the XML are not present in the target location this switch will remove these entries from database. And if there are new files this switch will add entries to the database for these files.

Required? False
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? False

-Quiet <SwitchParameter>

When script finishes the job, it exitss the PowerShell session with a numeric exit code. The exit codes are described in Outputs section.

Required? False
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? False

-NoStatistic <SwitchParameter>

Instrusts the command to not store detailed statistics per each file. This switch improves script performance.

Required? False
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? False

-Online <SwitchParameter>

Performs file hash calculation and passes output to the pipeline. When this switch is set to True, XML database is not used. This switch is useful when you just need to calculate hashes over a set of files.

Required? False
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? False

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, InformationAction, InformationVariable,
WarningAction, WarningVariable, OutBuffer, PipelineVariable and OutVariable.
For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

Inputs

System.String

Outputs

PSObject

Notes

Author: Vadims Podans
Blog: https://www.sysadmins.lv

Examples

Example 1

PS C:\> Start-PsFCIV -Path C:\tmp -XML DB.XML

Checks all files in C:\tmp folder by using SHA1 hash algorithm and compares them with information stored in the DB.XML database.

Example 2

PS C:\> Start-PsFCIV -Path C:\tmp -XML DB.XML -HashAlgorithm SHA1, SHA256, SHA512 -Recurse

Checks all files in C:\tmp folder and subfolders by using SHA1, SHA256 and SHA512 algorithms.

Example 3

PS C:\> Start-PsFCIV -Path C:\tmp -Include *.txt -XML DB.XML -HashAlgorithm SHA512

Checks all TXT files in C:\tmp folder by using SHA512 hash algorithm.

Example 4

PS C:\> Start-PsFCIV -Path C:\tmp -XML DB.XML -Rebuild

Rebuilds DB file, by removing all unused entries (when an entry exists, but the file does not exist) from the XML file and add all new files that has no records in the XML file using SHA1 algorithm. Existing files are not checked for integrity consistence.

Example 5

PS C:\> Start-PsFCIV -Path C:\tmp -XML DB.XML -HashAlgorithm SHA256 -Action Rename

Checks all files in C:\tmp folder using SHA256 algorithm and renames files with Length, LastWriteTime or hash mismatch by adding .BAD extension to them. The 'Delete' action can be appended to delete all bad files.

Example 6

PS C:\> Start-PsFCIV -Path C:\tmp -XML DB.XML -Show Ok, Bad

Checks all files in C:\tmp folder using SHA1 algorithm and shows filenames that match Ok or Bad category.

Related links

Minimum PowerShell version support

  • PowerShell 3.0

Operating System Support

  • Windows Vista
  • Windows 7
  • Windows 8
  • Windows 8.1
  • Windows 10
  • Windows Server 2008 all editions
  • Windows Server 2008 R2 all editions
  • Windows Server 2012 all editions
  • Windows Server 2012 R2 all editions
  • Windows Server 2016 all editions

Share this article: