I need to remove properties from multiple places with powershell script. I tried many examples from net, with null assigning and using remove on Properties and AllProperties, or using method DeleteProperty, but the most I managed is to remove value. Can anyone suggest how to do that?

Edit: Well the problem was kinda project related, because custom tools displayed needed to delete keys on different casing than they really was and what confused me was, that the script could find properties with wrong casing key, but couldn't delete it. Other than that the simplest way is as bunzab had told

有帮助吗?

解决方案

A couple of things:

Do not use Properties instead use AllProperties! There are methods on SPWeb to add update and delete property bag values and you should use them rather than dictionary methods on the property bag itself:

$web.DeleteProperty($key)

Kalpesh's comment is correct you can not delete a property from Properties but you can from AllProperties.

其他提示

Using PowerShell script you can use below cmdlets to remove the web properties.

$web = Get-SPWeb <url>
$web.Properties.Remove('test') // this is a key
$web.Update()
$web.Properties

Hope this helps to resolve your query.

Its simple...

Access AllProperties then remove that specific property.

Note: AllProperties are not accessible by default. You need to explicitly Load CSOM properties.

Here is the code

$web.AllProperties["Property_To_Remove"].Remove
许可以下: CC-BY-SA归因
scroll top