Powershell 删除隐藏数据和;个人资料“;来自';。文件'';。docx&x27;和';。pptx';文件
您好,我正在尝试通过powershell删除“.doc、.docx、.pptx”文档摘要的“隐藏数据”和个人信息集: 下面是我为同样的目的编写的powershell脚本:Powershell 删除隐藏数据和;个人资料“;来自';。文件'';。docx&x27;和';。pptx';文件,powershell,ms-word,Powershell,Ms Word,您好,我正在尝试通过powershell删除“.doc、.docx、.pptx”文档摘要的“隐藏数据”和个人信息集: 下面是我为同样的目的编写的powershell脚本: $path = "C:\Users\anisjain\Documents\GRR Production\HiddenProrerties" Add-Type -AssemblyName Microsoft.Office.Interop.Word $xlRemoveDocType = "Microsoft.Office.Int
$path = "C:\Users\anisjain\Documents\GRR Production\HiddenProrerties"
Add-Type -AssemblyName Microsoft.Office.Interop.Word
$xlRemoveDocType = "Microsoft.Office.Interop.xlRDIRemovePersonalInformation" -as [type]
$wordFiles = Get-ChildItem -Path $path -include *.doc, *.docx -recurse
$objword = New-Object -ComObject word.application
foreach($obj in $wordFiles)
{
$documents = $MSWord.Documents.Open($obj.fullname)
"Removing document information from $obj"
$documents.RemoveDocumentInformation($xlRemoveDocType::xlRDIRemovePersonalInformation)
$documents.Save()
$objword.documents.close()
}
$objword.Quit()
然而,这是行不通的。有人能告诉我哪里出了问题吗?
如果有其他方法的话。我有大约2000条记录,希望从中删除“隐藏的文档信息”。提前谢谢 在谷歌搜索/复制/修改之后,这是一个适合我的脚本
$path = "d:\rubbish\myfolder\"
Add-Type -AssemblyName Microsoft.Office.Interop.Word
$WdRemoveDocType = "Microsoft.Office.Interop.Word.WdRemoveDocInfoType" -as [type]
$wordFiles = Get-ChildItem -Path $path -include *.doc, *.docx -recurse
$objword = New-Object -ComObject word.application
$objword.visible = $false
foreach($obj in $wordFiles)
{
$documents = $objword.Documents.Open($obj.fullname)
"Removing document information from $obj"
# WdRemoveDocInfoType Enumeration Reference
# http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.wdremovedocinfotype(v=office.14).aspx
# 99 = WdRDIAll
#$documents.RemoveDocumentInformation(99)
$documents.RemoveDocumentInformation($WdRemoveDocType::wdRDIAll)
$documents.Save()
$objword.documents.close()
}
$objword.Quit()
在谷歌搜索/复制/修改之后,这是一个适合我的脚本
$path = "d:\rubbish\myfolder\"
Add-Type -AssemblyName Microsoft.Office.Interop.Word
$WdRemoveDocType = "Microsoft.Office.Interop.Word.WdRemoveDocInfoType" -as [type]
$wordFiles = Get-ChildItem -Path $path -include *.doc, *.docx -recurse
$objword = New-Object -ComObject word.application
$objword.visible = $false
foreach($obj in $wordFiles)
{
$documents = $objword.Documents.Open($obj.fullname)
"Removing document information from $obj"
# WdRemoveDocInfoType Enumeration Reference
# http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.wdremovedocinfotype(v=office.14).aspx
# 99 = WdRDIAll
#$documents.RemoveDocumentInformation(99)
$documents.RemoveDocumentInformation($WdRemoveDocType::wdRDIAll)
$documents.Save()
$objword.documents.close()
}
$objword.Quit()
它到底是如何“不起作用的”?$XLRemoveOctype::XLRDRemovePersonalInformation的值是否为4?(严格地说,我认为您应该使用等效的Word常量,但在许多情况下(如果不是所有情况下),它们似乎与Excel常量具有相同的值)它到底是如何“不起作用”的呢?$XLRemoveOctype::XLRDRemovePersonalInformation的值是否为4?(严格来说,我认为您应该使用等效的Word常量,但在许多情况下(如果不是所有情况下),它们似乎与Excel常量具有相同的值)