Project

PSWriteOffice

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

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Protect-OfficeExcelSheet

Aliases: ExcelProtect
Module
PSWriteOffice
Aliases
ExcelProtect
Inputs
OfficeIMO.Excel.ExcelDocument

Protects the current worksheet.

Syntax

Protect-OfficeExcelSheet
[-AllowAutoFilter <Boolean>]
[-AllowDeleteColumns <Boolean>]
[-AllowDeleteRows <Boolean>]
[-AllowFormatCells <Boolean>]
[-AllowFormatColumns <Boolean>]
[-AllowFormatRows <Boolean>]
[-AllowInsertColumns <Boolean>]
[-AllowInsertHyperlinks <Boolean>]
[-AllowInsertRows <Boolean>]
[-AllowPivotTables <Boolean>]
[-AllowSelectLockedCells <Boolean>]
[-AllowSelectUnlockedCells <Boolean>]
[-AllowSort <Boolean>]
[-AllowTableEditing]
[-PassThru]
[<CommonParameters>]
#
Parameter set: Context
Protect-OfficeExcelSheet
[-AllowAutoFilter <Boolean>]
[-AllowDeleteColumns <Boolean>]
[-AllowDeleteRows <Boolean>]
[-AllowFormatCells <Boolean>]
[-AllowFormatColumns <Boolean>]
[-AllowFormatRows <Boolean>]
[-AllowInsertColumns <Boolean>]
[-AllowInsertHyperlinks <Boolean>]
[-AllowInsertRows <Boolean>]
[-AllowPivotTables <Boolean>]
[-AllowSelectLockedCells <Boolean>]
[-AllowSelectUnlockedCells <Boolean>]
[-AllowSort <Boolean>]
[-AllowTableEditing]
-Document <ExcelDocument>
[-PassThru]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]
#
Parameter set: Document

Examples

Protect the active sheet with default options.

ExcelSheet 'Data' { Protect-OfficeExcelSheet }

Enables worksheet protection.

Parameters

-AllowAutoFilter Boolean optional
Allow AutoFilter.
-AllowDeleteColumns Boolean optional
Allow deleting columns.
-AllowDeleteRows Boolean optional
Allow deleting rows.
-AllowFormatCells Boolean optional
Allow formatting cells.
-AllowFormatColumns Boolean optional
Allow formatting columns.
-AllowFormatRows Boolean optional
Allow formatting rows.
-AllowInsertColumns Boolean optional
Allow inserting columns.
Allow inserting hyperlinks.
-AllowInsertRows Boolean optional
Allow inserting rows.
-AllowPivotTables Boolean optional
Allow PivotTables.
-AllowSelectLockedCells Boolean optional
Allow selecting locked cells.
-AllowSelectUnlockedCells Boolean optional
Allow selecting unlocked cells.
-AllowSort Boolean optional
Allow sorting.
-AllowTableEditing SwitchParameter optional
Allow common protected-table workflows: selecting cells, inserting rows, sorting, and filtering.
-PassThru SwitchParameter optional
Emit the worksheet after protection.
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
Workbook to operate on outside the DSL context.
-Sheet String optionalsets: Document
Worksheet name when using Document.
-SheetIndex Int32 optionalsets: Document
Worksheet index (0-based) when using Document.

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.