谁能帮我解决以下问题。

###############################
# 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"
}

最佳答案

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

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

您可以使用set-itemproperty进行相同的操作:
 Get-ChildItem "D:\testfolder" | Get-ItemProperty | Set-ItemProperty -name IsReadOnly -value $false

关于powershell - 属性System.Boolean IsReadOnly = False,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40299027/

10-11 07:47