0

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

2

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.

  • I have given comments based on SPWeb.Properties still we cannot delete property from SPWeb.Properties if SPWeb is root web as users1100 said. You can try by your self – Kalpesh Vaghela Jun 5 '15 at 6:35
  • Yeah sorry my bad edited to reflect that.. – Bunzab Jun 5 '15 at 6:46
0

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.

  • We cannot delete SPWeb Property once its added. We can just clear it's value. – Kalpesh Vaghela Jun 5 '15 at 6:17
  • As per my knowledge, if it is sub web then we can delete it. – users1100 Jun 5 '15 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.