Quantcast
Viewing all articles
Browse latest Browse all 17574

PowerShell to Clear (Delete) Values in Site Columns (Fields)

Hi all,

I need to clear the values of site columns in bulk. These range in type from single text to managed metadata values. I am able to add values via my script, but was wondering if anyone had guidance (not just sending me a link to what you googled unless it directly illustrates the issue, as I have searched as well). Here is my script that adds values. I am able to add MM values so long as I get the ID from the taxonomy hidden list (ex. 15;#myterm):

$web = Get-SPWeb http://mycompanysite.com/test
$list = $web.lists["Test"]
$CSVcnt= 0
$items = $list.getItems()
foreach($i in Import-CSV C:\PowerShell\EditListItemValues.csv)
{
$listCnt = 0;
Foreach($item in $items){
If($item["Name"] -eq $i.AnchorAttribute) {
$item["test1"] = $i.Attribute1
$item["test2"] = $i.Attribute2
$item["test3"] = $i.Attribute3
$item["test4"] = $i.Attribute4
$item.update()
}
}
}


Personal Blog: http://thebitsthatbyte.com


Viewing all articles
Browse latest Browse all 17574

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>