Remove-OfficeHiddenData
Writes a copy of a file without its metadata and hidden data, and reports what happened to each item.
Syntax
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.docxClean 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 $optionsAccept 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 -NoClobberParameters
- -NoClobber SwitchParameter
- Refuse to replace an existing output file.
- -Options OfficeHiddenDataOptions
- Categories to remove and how to treat tracked changes and provenance, from New-OfficeHiddenDataOptions. Defaults to the Default categories.
- -OutputPath String
- The cleaned copy for a single input. It must keep the input's extension.
- -Path String[]
- Files to clean; supports wildcards.
- -RemoveInvalidatedSignatures SwitchParameter
- Allow cleaning to remove Office package signatures that it invalidates; otherwise a signed package is refused.
- -OutputDirectory String
- Folder that receives each cleaned copy under its original file name; created when missing.
- -LiteralPath String[]
- 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.