gpt4 book ai didi

powershell - 属性System.Boolean IsReadOnly = False

转载 作者:行者123 更新时间:2023-12-02 23:24:41 26 4
gpt4 key购买 nike

谁能帮我解决以下问题。

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

Message Executed as user: abc\ankq_adc_AGd_extr. Set-ItemProperty : The property System.Boolean IsReadOnly=False does not exist or was not found. At 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], IOExcept ion + FullyQualifiedErrorId : SetPropertyError,Microsoft.PowerShell.Commands.SetItemPropertyCommand. Process Exit Code 1. The step failed.

最佳答案

您不需要使用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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com