Powershell 属性System.Boolean IsReadOnly=False

Powershell 属性System.Boolean IsReadOnly=False,powershell,sql-server-2014,Powershell,Sql Server 2014,有人能帮我解决以下问题吗 ############################### # retrieve Rule Definitions ############################### AGTrace "" AGTrace "=====================================" AGTrace "Retrieving AGTL Rule Definitions" AGTrace "==================================

有人能帮我解决以下问题吗

###############################
# retrieve Rule Definitions
###############################
AGTrace ""
AGTrace "====================================="
AGTrace "Retrieving AGTL Rule Definitions"
AGTrace "====================================="
#remove read-only flag on local rule definitions
try {
    Get-ChildItem "$LocalPath\ruledefinitions" | Set-ItemProperty -name IsReadOnly -value $false
} catch {
    Write-host "Unable to clear read-only flag"
    Write-host $error[0].exception.message
}
Copy-Files -SourceFolder "$AGSource\AGTL\RuleDefinitions" -DestFolder "$LocalPath\ruledefinitions" 

AGTrace ""
AGTrace "====================================="
AGTrace "Retrieving $AGID Rule Definitions"
AGTrace "====================================="
if (test-path "$AGSource\$AGID\RuleDefinitions") {
    AGTrace "Rule Definitions exist for $AGID"
    Copy-Files -SourceFolder "$AGSource\$AGID\RuleDefinitions" -DestFolder "$LocalPath\ruledefinitions"
} else {
    AGTrace "No Rule Definitions exist for $AGID"
}
作为用户执行的消息:abc\ankq\u adc\u AGd\u extr。设置项目属性: 属性System.Boolean IsReadOnly=False不存在或不存在 建立在 E:\AGD4.0.1\Full\DW提取器\AGDiagnostics\U R4.0.1\U CORESTALL\AG4STG\U 4.0.0\execute\U load\U JP.ps1:145 char:47+获取子项“$LocalPath\SupplementalAGta”| Set-ItemProperty-名称为只读+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~类别信息: ReadError:(System.Boolean IsReadOnly=False:PSNoteProperty) [Set-ItemProperty],IOIon+FullyQualifiedErrorId除外: SetPropertyError,Microsoft.PowerShell.Commands.SetItemPropertyCommand。 进程退出代码1。步骤失败了


您不需要使用set-itemproperty,将属性更改为只读时,下面的代码应该可以使用:

 Get-ChildItem "D:\testfolder" | %{$_.isreadonly = $true}
您可以对set-itemproperty执行相同的操作:

 Get-ChildItem "D:\testfolder" | Get-ItemProperty | Set-ItemProperty -name IsReadOnly -value $false

我现在就查@Abhijith。谢谢你的帮助response@SQLBoy如果目标文件夹中包含文件夹,则您可能必须添加一个检查,以便仅对文件夹中的文件应用此项,因为此项仅适用于fileSure@Abhijith,非常感谢,请告诉我此错误是否与版本有关。为什么会发生此错误?