属性System.Boolean IsReadOnly = False

时间:2016-10-28 06:10:26

标签: powershell sql-server-2014

任何人都可以帮我解决以下问题。

###############################
# 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。 Set-ItemProperty:   System.Boolean IsReadOnly = False属性不存在或不存在   找到。在   E:\ AGD4.0.1 \完全\ DW-提取\ AGDiagnostics_R4.0.1_CoreInstall \ AG4STG_4.0.0 \ execute_load_JP.ps1:145   char:47 + Get-ChildItem“$ LocalPath \ SupplementalAGta”|   Set-ItemProperty -name IsReadOnly ... +
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ClassInfo:   ReadError:(System.Boolean IsReadOnly = False:PSNoteProperty)   [Set-ItemProperty],IOExcept ion + FullyQualifiedErrorId:   SetPropertyError,Microsoft.PowerShell.Commands.SetItemPropertyCommand。   处理退出代码1.步骤失败。

1 个答案:

答案 0 :(得分:3)

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

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

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

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