powershell - 属性System.Boolean IsReadOnly = False

标签 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"
}

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/

相关文章:

PowerShell:是否可以编写一个引用其文件夹中的文件的脚本,无论从哪里调用它仍然可以工作?

sql-server - 选择不在另一个表中的键需要永远

c# - Websocket 在 mssqlserver 中每分钟运行一次查询

visual-studio-2013 - 如何在 Visual Studio 2013 数据库项目中添加新架构

powershell - 使 PowerShell 脚本在全局范围内运行 cmdlet

powershell - 使用 Powershell 检索注册表值时出错

powershell - 如何通过powershell将计算机加入域

sql-server - 将函数与 OUTER APPLY 一起使用时,返回值而不是 NULL

sql-server-2014 - 最大行大小超过了允许的最大值 8060 字节

sql - 如何在 "SQL Server Maintenance"计划结束后运行程序或 PowerShell 脚本?