# Add-OfficeExcelPowerQueryMetadata

Adds safe Power Query/connection metadata for Excel-compatible applications to own and refresh.

Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

[View on GitHub](https://github.com/EvotecIT/OfficeIMO/tree/master/PowerShell/PSWriteOffice) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSWriteOffice/releases/tag/v3.0.5) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSWriteOffice/0.2.0)

Stars **725**

Forks **84**

Open issues **3**

Total downloads **5,231,343**

Release **OfficeIMO-v3.6.2**

Language: C# Updated: 2026-11-23

Cmdlet 

Aliases: ExcelPowerQueryMetadata, ExcelQueryMetadata

**Module**

`PSWriteOffice`

**Aliases**

`ExcelPowerQueryMetadata` `ExcelQueryMetadata`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Outputs**

`System.Management.Automation.PSObject`

**Source**

[AddOfficeExcelPowerQueryMetadataCommand.cs:24](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Excel/AddOfficeExcelPowerQueryMetadataCommand.cs#L24) 

Adds safe Power Query/connection metadata for Excel-compatible applications to own and refresh.

## Syntax

```
Add-OfficeExcelPowerQueryMetadata
[-CommandText <String>]
[-Description <String>]
-Name <String>
[-PassThru]
[-QueryTableName <String>]
[-RefreshOnOpen]
[-WorksheetName <String>]
[<CommonParameters>]
```

[#](#method-add-officeexcelpowerquerymetadata-string-string-string-switchparameter-string-switchparameter-string)

Parameter set: `Context`

```
Add-OfficeExcelPowerQueryMetadata
[-CommandText <String>]
[-Description <String>]
-Name <String>
[-PassThru]
[-Path] <String>
[-QueryTableName <String>]
[-RefreshOnOpen]
[-WorksheetName <String>]
[<CommonParameters>]
```

[#](#method-add-officeexcelpowerquerymetadata-string-string-string-switchparameter-string-string-switchparameter-string)

Parameter set: `Path`

```
Add-OfficeExcelPowerQueryMetadata
[-CommandText <String>]
[-Description <String>]
-Document <ExcelDocument>
-Name <String>
[-PassThru]
[-QueryTableName <String>]
[-RefreshOnOpen]
[-WorksheetName <String>]
[<CommonParameters>]
```

[#](#method-add-officeexcelpowerquerymetadata-string-string-exceldocument-string-switchparameter-string-switchparameter-string)

Parameter set: `Document`

## Examples

### Add a workbook connection and worksheet query-table metadata.

```powershell
Add-OfficeExcelPowerQueryMetadata -Path .\Report.xlsx `
                -Name SalesQuery `
                -WorksheetName Data `
                -CommandText 'let Source = Excel.CurrentWorkbook(){[Name="Sales"]}[Content] in Source' `
                -Description 'Sales query metadata authored by automation' `
                -RefreshOnOpen `
                -PassThru
```

Writes package metadata only. OfficeIMO does not execute Power Query M; Excel-compatible applications perform refresh when opened.

## Parameters

**-CommandText String optional**

Power Query M expression stored as metadata.

**-Description String optional**

Connection description.

**-Name String required**

Connection name stored in workbook metadata.

**-PassThru SwitchParameter optional**

Emit metadata about the authored package parts.

**-QueryTableName String optional**

Optional query-table name.

**-RefreshOnOpen SwitchParameter optional**

Request refresh-on-open metadata.

**-WorksheetName String optionalaliases: Sheet, SheetName, Worksheet**

Worksheet that should own query-table metadata. Defaults to the current DSL sheet when used inside New-OfficeExcel.

**-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path**

Workbook path to update.

**-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document**

Workbook document to update.

## Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see [about_CommonParameters](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:A4550DE5811776A7388FC1BF2D1126B13E03CBD7E6D4B97E806269CF0E2B3781 -->
