Cmdlet
Protect-OfficeExcelWorkbook
Protects workbook structure or windows metadata. This is not file encryption.
Syntax
Protect-OfficeExcelWorkbook [-LegacyPasswordHash <String>] [-NoStructure] [-PassThru] [-Password <String>] [-ProtectWindows] [<CommonParameters>]#Parameter set:
ContextProtect-OfficeExcelWorkbook [-LegacyPasswordHash <String>] [-NoStructure] [-PassThru] [-Password <String>] [-Path] <String> [-ProtectWindows] [<CommonParameters>]#Parameter set:
PathProtect-OfficeExcelWorkbook -Document <ExcelDocument> [-LegacyPasswordHash <String>] [-NoStructure] [-PassThru] [-Password <String>] [-ProtectWindows] [<CommonParameters>]#Parameter set:
DocumentExamples
Prevent worksheet add/delete/move/rename operations in Excel UI.
Protect-OfficeExcelWorkbook -Path .\Report.xlsx -Password secret
Test-OfficeExcelWorkbook -Path .\Report.xlsx -SkipOpenXmlValidation |
Select-Object Passed, ProtectionSummaryWrites workbook-level structure protection metadata and saves the workbook.
Parameters
- -LegacyPasswordHash String
- Optional precomputed legacy workbook protection hash to write as-is.
- -NoStructure SwitchParameter
- Do not protect workbook structure.
- -PassThru SwitchParameter
- Emit the workbook after protection.
- -Password String
- Optional workbook protection password. This is UI protection, not package encryption.
- -ProtectWindows SwitchParameter
- Protect workbook windows where supported by the consuming application.
- -Path String
- Workbook path to update.
- -Document ExcelDocument
- 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.