Solved

Powershell script needed to update a field in Sharepoint list

Posted on 2010-11-11
1
809 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 500 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now