SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to have a PowerShell script that can modify some item's values in a SharePoint 2007 List or SharePoint Document Library on the last day at 2359 Hrs every month? (If it is possible, it would be nice if can list out links on doing it.)

share|improve this question
up vote 1 down vote accepted

To run the script at the time interval you specify, you would have to write the script and then use task scheduler on one of your servers to run the script. You might run into security permissions, here is a good thread on doing it.

The script to run is fairly simple

# ------ [ Configuration Section ] ----------------------------------------

$url = "http://localhost/sites/Test"
$listname = "NameOfList"
$fieldname = "Title"
Add-PSSnapin microsoft.sharepoint.powershell

#open output file
$filename = (Get-Date).ToString("u").Replace(":","").Replace(" ","").Replace("-","")+ $url.Replace(":","").Replace(".","").Replace("/","") + "thisiswhatscriptdoes.txt"
$outfile = New-Item -type file $filename

#open the web
$gc = Start-SPAssignment
$web = $gc | Get-SPWeb $url

#open the list 
$list = $web.Lists[$listname]

#Get and store list items in a local variable
$items = [Microsoft.SharePoint.SPListItemCollection] $list.GetItems()

for ($i = 0; $i -lt $list.ItemCount; $i++)
    #set local item to loops current item
    $item = [Microsoft.SharePoint.SPListItem] $items[$i]  

    #configure your field edit and output line here, maybe make it an if statement if need be
    $item[$fieldname] = "New Title"
    $outline = $item[$fieldname] + $item.URL
    Add-Content $outfile $outline

}#end of main for loop

Stop-SPAssignment $gc
share|improve this answer

Your Answer


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

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