【问题标题】:The property System.Boolean IsReadOnly=False属性 System.Boolean IsReadOnly=False
【发布时间】:2016-10-28 06:10:26
【问题描述】:

谁能帮我解决以下问题。

###############################
# 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_adc_AGd_extr。设置项目属性: 属性 System.Boolean IsReadOnly=False 不存在或不存在 成立。在 E:\AGD4.0.1\Full\DW-Extractor\AGDiagnostics_R4.0.1_CoreInstall\AG4STG_4.0.0\execute_load_JP.ps1:145 char:47 + Get-ChildItem "$LocalPath\SupplementalAGta" | Set-ItemProperty -name IsReadOnly ... +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ReadError: (System.Boolean IsReadOnly=False:PSNoteProperty) [Set-ItemProperty],IOException + FullyQualifiedErrorId : SetPropertyError,Microsoft.PowerShell.Commands.SetItemPropertyCommand。 处理退出代码 1。该步骤失败。

【问题讨论】:

    标签: powershell sql-server-2014


    【解决方案1】:

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

     Get-ChildItem "D:\testfolder" | %{$_.isreadonly = $true}
    

    你可以用 set-itemproperty 做同样的事情:

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

    【讨论】:

    • 我现在会检查@Abhijith。感谢您的回复
    • @SQLBoy 如果目标文件夹中包含文件夹,那么您可能必须添加一个检查,以便仅将其应用于文件夹内的文件,因为这仅适用于文件
    • 当然@Abhijith,非常感谢
    • ,请问这个错误是否与版本有关。为什么会出现这个错误?
    猜你喜欢
    • 2013-06-15
    • 1970-01-01
    • 2012-08-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多