API Reference
Cmdlet
Protect-OfficeExcelWorkbook
Protects workbook structure or windows metadata. This is not file encryption.
Remarks
Protects workbook structure or windows metadata. This is not file encryption.
Examples
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:
ContextParameters
- 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.
Outputs
OfficeIMO.Excel.ExcelDocument System.IO.FileInfo
Protect-OfficeExcelWorkbook -InputPath <String> [-LegacyPasswordHash <String>] [-NoStructure] [-PassThru] [-Password <String>] [-ProtectWindows] [<CommonParameters>]#Parameter set:
PathParameters
- InputPath String
- Workbook path to update.
- 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.
Outputs
OfficeIMO.Excel.ExcelDocument System.IO.FileInfo
Protect-OfficeExcelWorkbook -Document <ExcelDocument> [-LegacyPasswordHash <String>] [-NoStructure] [-PassThru] [-Password <String>] [-ProtectWindows] [<CommonParameters>]#Parameter set:
DocumentParameters
- Document ExcelDocument
- Workbook to update outside the DSL context.
- 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.
Outputs
OfficeIMO.Excel.ExcelDocument System.IO.FileInfo