Powershell 设置PDF文件的只读
当前我的只读函数未设置PDF文件的只读Powershell 设置PDF文件的只读,powershell,pdf,Powershell,Pdf,当前我的只读函数未设置PDF文件的只读 function SetFolderItemsReadOnly{ Param([string]$Path) $files = Get-ChildItem $Path -File -ErrorAction SilentlyContinue foreach($file in $files) { Set-ItemProperty -Path $file.FullName -Name IsReadOnly -Value $t
function SetFolderItemsReadOnly{
Param([string]$Path)
$files = Get-ChildItem $Path -File -ErrorAction SilentlyContinue
foreach($file in $files) {
Set-ItemProperty -Path $file.FullName -Name IsReadOnly -Value $true
}
}
如何处理pdf文件?在get-childitem和set-itemproperty中使用-literalpath
信用:@wOxxOm无法复制。该文件可能已在其他位置打开。或者将PDF内部修改保护与文件系统只读属性混淆。@wOxxOm哦,你说得对。当文件名中出现类似于[或]的内容时,就会出现问题。@BenjaminS.sorterrup在调用中使用LiteralPath而不是Path。@BenjaminS.sorterrup尝试使用
-LiteralPath
而不是-Path
使用-LiteralPath
获取childitem和设置itemproperty