2016-10-28 5 views
1

誰でも下の問題で私を助けることができます。プロパティSystem.Boolean IsReadOnly = False

あなたは以下のコードが読み取り専用するプロパティを変更するため問題ないはずです、セットitempropertyを使用する必要はありません
############################### 
# 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.

答えて

2

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

あなたは、セットitempropertyと同じ操作を行うことができます。

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

先フォルダは、あなたが持つかもしれない内部のフォルダが含まれている場合、私は応答 – SQLBoy

+0

@SQLBoyためAbhijith.Thanks @今チェックしますこれはファイルにのみ適用されるので、これはフォルダ内のファイルにのみ適用するためのチェックを追加する –

+0

確かに@ Abhijith、ありがとうたくさん – SQLBoy

関連する問題