Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I created the next script with powershell and it updates all the items in a list:

Add-PSSnapin "Microsoft.Sharepoint.Powershell"
$site = Get-SPWeb -identity "http://mywebsite"
$list = $site.Lists["List"] 
$spitems = $list.items 
foreach($item in $spitems){
    [Microsoft.SharePoint.SPListItem]$spListItem = $item
    $spListItem.Update(); 

}

It's executes very well. But my problem is the next. When I add or modify a item in this list, this script are executed, I don't want this. How can I stop this script? Thank you.

share|improve this question
    
What is the purpose of this script? To update the timestamps? –  RJ Cuthbertson Jul 30 '12 at 14:02
    
The purpose of this script it's to update every item in a Sharepoint List. But my problem is when I modify the Sharepoint List, the script executes too. The script I execute only 1 time. –  Albert Jul 30 '12 at 14:08
    
How would this script run every time you update the list? Did you attach it to an event receiver? Also, why are you updating every item in the list? You aren't changing anything except the timestamps. What is the purpose of this? –  RJ Cuthbertson Jul 30 '12 at 14:12
    
When do you want this to fire? Also, you do not dispose of any items, make sure you dispose of your SP objects... –  Mike Jul 30 '12 at 14:13
    
The objective of this script it's to update every item in the list because we want to update a certain columns with dates. By default Sharepoint doesn't have a system to update the items of one list automatically. Why executes automatically the script every time I modify a item? –  Albert Jul 30 '12 at 14:19
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.