API Reference

Cmdlet

Protect-OfficeExcelWorkbook

Aliases: ExcelWorkbookProtect
Namespace PSWriteOffice
Aliases
ExcelWorkbookProtect
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
OfficeIMO.Excel.ExcelDocument System.IO.FileInfo

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

Remarks

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

Examples

Authored help example

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

PS>


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.

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.

Syntax

Protect-OfficeExcelWorkbook [-LegacyPasswordHash <String>] [-NoStructure] [-PassThru] [-Password <String>] [-ProtectWindows] [<CommonParameters>]
#
Parameter set: Context

Parameters

LegacyPasswordHash String optionalposition: namedpipeline: False
Optional precomputed legacy workbook protection hash to write as-is.
NoStructure SwitchParameter optionalposition: namedpipeline: False
Do not protect workbook structure.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the workbook after protection.
Password String optionalposition: namedpipeline: False
Optional workbook protection password. This is UI protection, not package encryption.
ProtectWindows SwitchParameter optionalposition: namedpipeline: False
Protect workbook windows where supported by the consuming application.

Outputs

OfficeIMO.Excel.ExcelDocument System.IO.FileInfo

Protect-OfficeExcelWorkbook -InputPath <String> [-LegacyPasswordHash <String>] [-NoStructure] [-PassThru] [-Password <String>] [-ProtectWindows] [<CommonParameters>]
#
Parameter set: Path

Parameters

InputPath String requiredposition: 0pipeline: Falsealiases: FilePath, Path
Workbook path to update.
LegacyPasswordHash String optionalposition: namedpipeline: False
Optional precomputed legacy workbook protection hash to write as-is.
NoStructure SwitchParameter optionalposition: namedpipeline: False
Do not protect workbook structure.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the workbook after protection.
Password String optionalposition: namedpipeline: False
Optional workbook protection password. This is UI protection, not package encryption.
ProtectWindows SwitchParameter optionalposition: namedpipeline: False
Protect workbook windows where supported by the consuming application.

Outputs

OfficeIMO.Excel.ExcelDocument System.IO.FileInfo

Protect-OfficeExcelWorkbook -Document <ExcelDocument> [-LegacyPasswordHash <String>] [-NoStructure] [-PassThru] [-Password <String>] [-ProtectWindows] [<CommonParameters>]
#
Parameter set: Document

Parameters

Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook to update outside the DSL context.
LegacyPasswordHash String optionalposition: namedpipeline: False
Optional precomputed legacy workbook protection hash to write as-is.
NoStructure SwitchParameter optionalposition: namedpipeline: False
Do not protect workbook structure.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the workbook after protection.
Password String optionalposition: namedpipeline: False
Optional workbook protection password. This is UI protection, not package encryption.
ProtectWindows SwitchParameter optionalposition: namedpipeline: False
Protect workbook windows where supported by the consuming application.

Outputs

OfficeIMO.Excel.ExcelDocument System.IO.FileInfo