Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Powershell script needed to update a field in Sharepoint list

Posted on 2010-11-11
1
Medium Priority
?
837 Views
Last Modified: 2012-05-10
I have a Powershell script that prompts for a project number, then performs a series of file and directory operations, but after it completes those operations I need it to locate an item in my Sharepoint "ProjectBid" list by "ProjectNum", then change the "Status" field to "Submitted"

Does anyone have a sample script that performs something like that?

Thank You,

Jim
0
Comment
Question by:jjeffcoat
1 Comment
 
LVL 16

Accepted Solution

by:
quihong earned 2000 total points
ID: 34113497
You're in luck.

Try something like the below. Double check the if syntax. There's probably better ways to pull out the exact listitem you want using a camel query but the below is simpler to understand and do.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
$SPSite = New-Object Microsoft.SharePoint.SPSite("http://server/sites/sitename")
$SPWeb = $SPSite.OpenWeb()
$SPList = $SPWeb.Lists["ProjectBid"]
foreach ($listItem in $SPList.Items)
{

    if ($listItem["ProjectNum"] -eq $yourProjectNumber)
    {
       $listItem["Status"] = "Submitted"
       $listItem.Update()
    }
}


$SPWeb.Dispose()
$SPSite.Dispose()

Open in new window

0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦
Screencast - Getting to Know the Pipeline

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question