# Protect-OfficeExcelWorkbook

Protects workbook structure or windows metadata. This is not file encryption.

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 **727**

Forks **84**

Open issues **7**

Total downloads **5,275,783**

Release **OfficeIMO-v3.6.2**

Language: C# Updated: 2026-11-24

Cmdlet 

Aliases: ExcelWorkbookProtect

**Module**

`PSWriteOffice`

**Aliases**

`ExcelWorkbookProtect`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Outputs**

`OfficeIMO.Excel.ExcelDocument` `System.IO.FileInfo`

**Source**

[ProtectOfficeExcelWorkbookCommand.cs:20](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Excel/ProtectOfficeExcelWorkbookCommand.cs#L20) 

Protects workbook structure or windows metadata. This is not file encryption.

## Syntax

```
Protect-OfficeExcelWorkbook
[-LegacyPasswordHash <String>]
[-NoStructure]
[-PassThru]
[-Password <String>]
[-ProtectWindows]
[<CommonParameters>]
```

[#](#method-protect-officeexcelworkbook-string-switchparameter-switchparameter-string-switchparameter)

Parameter set: `Context`

```
Protect-OfficeExcelWorkbook
[-LegacyPasswordHash <String>]
[-NoStructure]
[-PassThru]
[-Password <String>]
[-Path] <String>
[-ProtectWindows]
[<CommonParameters>]
```

[#](#method-protect-officeexcelworkbook-string-switchparameter-switchparameter-string-string-switchparameter)

Parameter set: `Path`

```
Protect-OfficeExcelWorkbook
-Document <ExcelDocument>
[-LegacyPasswordHash <String>]
[-NoStructure]
[-PassThru]
[-Password <String>]
[-ProtectWindows]
[<CommonParameters>]
```

[#](#method-protect-officeexcelworkbook-exceldocument-string-switchparameter-switchparameter-string-switchparameter)

Parameter set: `Document`

## Examples

### Prevent worksheet add/delete/move/rename operations in Excel UI.

```powershell
Protect-OfficeExcelWorkbook -Path .\Report.xlsx -Password secret
Test-OfficeExcelWorkbook -Path .\Report.xlsx -SkipOpenXmlValidation |
    Select-Object Passed, ProtectionSummary
```

Writes workbook-level structure protection metadata and saves the workbook.

## Parameters

**-LegacyPasswordHash String optional**

Optional precomputed legacy workbook protection hash to write as-is.

**-NoStructure SwitchParameter optional**

Do not protect workbook structure.

**-PassThru SwitchParameter optional**

Emit the workbook after protection.

**-Password String optional**

Optional workbook protection password. This is UI protection, not package encryption.

**-ProtectWindows SwitchParameter optional**

Protect workbook windows where supported by the consuming application.

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

Workbook path to update.

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

Workbook to update outside the DSL context.

## 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:00C8A20D3BC3EB2B0ED802F3E6ABB0876EDF64A1D530666ADA58C455E5D7299F -->
