Get-MSITable

Synopsis

Selects records from a table or custom query from a product or patch package.

Syntax

Get-MSITable [[-Path] <string[]>] -Table <string> [-Patch <string[]>] [-Transform <string[]>] [<CommonParameters>]

Get-MSITable [-Product] <ProductInstallation[]> -Query <string> [-IgnoreMachineState] [<CommonParameters>]

Get-MSITable [-Product] <ProductInstallation[]> -Table <string> [-IgnoreMachineState] [<CommonParameters>]

Get-MSITable -LiteralPath <string[]> -Query <string> [-Patch <string[]>] [-Transform <string[]>] [<CommonParameters>]

Get-MSITable -LiteralPath <string[]> -Table <string> [-Patch <string[]>] [-Transform <string[]>] [<CommonParameters>]

Get-MSITable [[-Path] <string[]>] -Query <string> [-Patch <string[]>] [-Transform <string[]>] [<CommonParameters>]

Description

You can query all records from a table or records matching a custom query from a product or patch package. The Windows Installer SDK has more information about custom queries, since the SQL-like syntax is rather constrained.

Records are returned with properties matching column names. If records are selected from a single table, the table name is also part of the type name queryable from the PSTypeNames object property. If the column name is prefixed with the table name - required to disambiguate names, or optional otherwise - a property is returned as typed in the original query string. Note that Windows PowerShell allows periods in property names but may require in some scenarios that a property name with periods is contained in quotes, like 'File.Attributes'.

For attribute columns in standard Windows Installer tables, you may also query for specific attribute values by specifying a special property name on the end of the attribute column name, like 'File.Attributes'.HasVital, to query for any columns that have the attribute value set. You can define an $MsiAttributeColumnFormat variable to control the display format of attribute columns, though the underlying value will not be changed. Run 'help about_MSI' for more information.

Note that patch packages do not typically have more than a couple of tables. The patch has to be applied to a product package to view any changes it has made.

Parameters

-IgnoreMachineState <SwitchParameter>

Whether to apply any patches current installed to the product.

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

-LiteralPath <string[]>

The path to a product package to open. 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

-Patch <string[]>

The path to a package package to apply to the product package. Multiple patches are applied in authored sequence order.

Wildcards are permitted. You can specify * in any part of the path to select all matching files.

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

-Path <string[]>

The path to a product package to open. Wildcards are permitted. 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

-Product <Microsoft.Deployment.WindowsInstaller.ProductInstallation[]>

An installed product to query.

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

-Query <String>

A custom query for which records are selected. Ambiguous column names must be prefixed with the table name to which they belong.

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

-Table <String>

The table from which all records are selected.

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

-Transform <string[]>

The path to a transform to apply to the product package.

Wildcards are permitted. You can specify * in any part of the path to select all matching files.

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

Inputs

  • Microsoft.Deployment.WindowsInstaller.ProductInstallation: An existing product to query. By default any patches already applied to the product are applied to the database.

Outputs

  • Microsoft.Tools.WindowsInstaller.Record: Selected records for a table or custom query where properties match column names.

Examples

Example 1

get-msitable .\example.msi -table Property
Gets all records from the Property table.

Example 2

$productCode = get-msitable .\example.msi -table Property | where-object { $_.Property -eq "ProductCode" } | select-object -expand Value
Selects just the ProductCode property from the example.msi package and assigns the value to a variable.

Example 3

get-childitem -filter *.msi | get-msitable -query "SELECT ComponentId, FileName, FileSize FROM Component, File WHERE Component_ = Component"
Selects the component GUID, file name, and file size for all files in all packages in the current directory.

Example 4

get-msitable .\example.msi -query "SELECT ComponentId, FileName, File.Attributes FROM Component, File WHERE Component_ = Component" | where-object { $_.'File.Attributes'.HasVital }
Selects all vital files and displays the component GUID, file name, and all file attribtes from the example.msi package.

Note that in the query filter the 'File.Attributes' column is contained in quotes; otherwise, Windows PowerShell will attempt to filter based on an Attributes property of a File property of the current pipeline object. The 'File.Attributes' column is contained in quotes in the original query because the Component table also contains a column named Attributes. Windows Installer requires that you disambiguate column names.

Example 5

get-msiproductinfo '{877EF582-78AF-4D84-888B-167FDC3BCC11}' | get-msitable -table Property
Selects records from the installed product along with any patches currently installed.

Related Links


Last edited Jul 2, 2013 at 7:55 AM by heaths, version 1

Comments

No comments yet.