Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Remove-OfficeHiddenData

Module
PSWriteOffice
Inputs
System.String[]
Outputs
PSWriteOffice.Models.OfficeHiddenDataFileReport

Writes a copy of a file without its metadata and hidden data, and reports what happened to each item.

Syntax

Remove-OfficeHiddenData
[-NoClobber]
[-Options <OfficeHiddenDataOptions>]
[-OutputPath <String>]
[-Path] <String[]>
[-RemoveInvalidatedSignatures]
[<CommonParameters>]
#
Parameter set: Path
Remove-OfficeHiddenData
[-NoClobber]
[-Options <OfficeHiddenDataOptions>]
-OutputDirectory <String>
[-Path] <String[]>
[-RemoveInvalidatedSignatures]
[<CommonParameters>]
#
Parameter set: PathDirectory
Remove-OfficeHiddenData
-LiteralPath <String[]>
[-NoClobber]
[-Options <OfficeHiddenDataOptions>]
[-OutputPath <String>]
[-RemoveInvalidatedSignatures]
[<CommonParameters>]
#
Parameter set: LiteralPath
Remove-OfficeHiddenData
-LiteralPath <String[]>
[-NoClobber]
[-Options <OfficeHiddenDataOptions>]
-OutputDirectory <String>
[-RemoveInvalidatedSignatures]
[<CommonParameters>]
#
Parameter set: LiteralPathDirectory

Description

The input is never changed. The cleaned copy is written as <name>.cleaned<ext> beside the input unless OutputPath or OutputDirectory says otherwise. An existing output file is replaced, as with Convert-OfficeDocument and Optimize-OfficePdf; NoClobber refuses it instead.

Without Options the Default categories are removed: document and custom properties, comments, personal identities, speaker notes, the thumbnail, custom XML, image metadata, printer settings, external references, document variables, revision identifiers and active content such as scripts. Tracked changes, hidden content, provenance, attachments and bookmarks are kept until New-OfficeHiddenDataOptions selects them. Every finding reports an Outcome; a Retained finding carries a Reason and a Note that say why it stayed.

Saving refuses to invalidate an Office package signature unless RemoveInvalidatedSignatures is present. Signed PDFs are always refused.

Examples

Write Proposal.cleaned.docx with the default categories removed.

Remove-OfficeHiddenData -Path .\Proposal.docx

Clean a folder into a share folder, also removing Content Credentials and AI labels.

$options = New-OfficeHiddenDataOptions -Kind Default, Provenance
Get-ChildItem .\Outgoing -File | Remove-OfficeHiddenData -OutputDirectory .\Share -Options $options

Accept tracked changes, and keep an earlier cleaned copy if one exists.

$options = New-OfficeHiddenDataOptions -TrackedChanges AcceptAll
Remove-OfficeHiddenData -Path .\Contract.docx -OutputPath .\Contract-final.docx -Options $options -NoClobber

Parameters

-NoClobber SwitchParameter optional
Refuse to replace an existing output file.
-Options OfficeHiddenDataOptions optional
Categories to remove and how to treat tracked changes and provenance, from New-OfficeHiddenDataOptions. Defaults to the Default categories.
-OutputPath String optionalsets: Path, LiteralPath
The cleaned copy for a single input. It must keep the input's extension.
-Path String[] requiredposition: 0pipeline: True (ByValue)sets: Path, PathDirectory
Files to clean; supports wildcards.
-RemoveInvalidatedSignatures SwitchParameter optional
Allow cleaning to remove Office package signatures that it invalidates; otherwise a signed package is refused.
-OutputDirectory String requiredsets: PathDirectory, LiteralPathDirectory
Folder that receives each cleaned copy under its original file name; created when missing.
-LiteralPath String[] requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath, LiteralPathDirectory
Exact file paths, including FileInfo.FullName and provider PSPath pipeline properties.

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.

Outputs

PSWriteOffice.Models.OfficeHiddenDataFileReport: Hidden data found in one file, what removal did with each item, and where the cleaned copy was written.