Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 设置PDF文件的只读_Powershell_Pdf - Fatal编程技术网

Powershell 设置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

当前我的只读函数未设置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 $true

    }
}

如何处理pdf文件?

在get-childitem和set-itemproperty中使用-literalpath


信用:@wOxxOm

无法复制。该文件可能已在其他位置打开。或者将PDF内部修改保护与文件系统只读属性混淆。@wOxxOm哦,你说得对。当文件名中出现类似于[或]的内容时,就会出现问题。@BenjaminS.sorterrup在调用中使用LiteralPath而不是Path。@BenjaminS.sorterrup尝试使用
-LiteralPath
而不是
-Path
使用
-LiteralPath
获取childitem和
设置itemproperty