Get-MSIFileHash

Synopsis

Gets a hash of a file in a Windows Installer-compatible format.

Syntax

Get-MSIFileHash [[-Path] <string[]>] [-PassThru] [<CommonParameters>]

Get-MSIFileHash -LiteralPath <string[]> [-PassThru] [<CommonParameters>]

Description

Get-MSIFileHash returns a 128-bit file hash in 4 separate parts, compatible with columns in the MsiFileHash table in Windows Installer packages. All non-versioned files should contain this hash.

You can optionally add these HashPart1, HashPart2, HashPart3, and HashPart4 properties to FileSystem items.

Parameters

-LiteralPath <string[]>

The path to the item or items which must resolve to a file system path. The value of -LiteralPath is used exactly as typed. No characters are interpreted as wildcards.

Required? true
Position named
Default value|
Accepts pipeline input? true (ByPropertyName)
Accept wildcard charactrs? false

-PassThru <SwitchParameter>

Passes the item or items passed into this cmdlet through the pipeline with additional properties for the file hash.

Required? false
Position named
Default value|
Accepts pipeline input? false
Accept wildcard charactrs? false

-Path <string[]>

The path to the item or items which must resolve to a file system path. You can specify * in any part of the path to select all matching files.

Required? false
Position 0
Default value|
Accepts pipeline input? true (ByValue, ByPropertyName)
Accept wildcard charactrs? true

Outputs

  • Microsoft.Tools.WindowsInstaller.FileHash: If -passthru is not specified, Get-MSIFileHash returns a FileHash object containing the file hash in 4 parts.
  • System.IO.DirectoryInfo: If -passthru is specified and the input object is a directory, the directory is returned.
  • System.IO.FileInfo: If -passthru is specified and the input object is a file, the file is returned.

Examples

Example 1

get-msifilehash -path * | format-table -auto

This command outputs the file hash of every file in the current directory as a table.

Example 2

get-childitem | where-object {$_.PSIsContainer -eq $False} | get-msifilehash -passthru | format-table Name, MSI* -auto

This command outputs the name and hash parts of each file in the current directory.

Related Links


Last edited Jun 11, 2013 at 10:38 AM by heaths, version 2

Comments

No comments yet.