Solved

Powershell script needed to update a field in Sharepoint list

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Set OWA language and time zone in Exchange for individuals, all users or per database.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

930 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

9 Experts available now in Live!

Get 1:1 Help Now