So we have an inventory list with details about each item, mostly drop down menus and check boxes, some comments and descriptions. These records are in SharePoint. Sometimes we need to update multiple items in there in addition to a large number of other steps and I am trying to automate most of these steps including the updates to their SharePoint record. What is the best way to go about this in PowerShell from any remote computer?
Would I connect to the database, find the record and and update the record there? Is there an easier way? I tried finding PowerShell CLI tools for SharePoint but I don't see them available anywhere.
For example, I might want to update this field here:
EDIT:
Here's the code I've tried but it does nothing at all for some reason, not even an error which means it's finding the list but... It's returning 0 items found for whatever reason.
class Program
{
static void Main(string[] args)
{
// Get the context
ClientContext context = new ClientContext("http://sp.mydomain.com/sites/ts/it/ITG");
// Get the list
List recordsList = context.Web.Lists.GetByTitle("ServerInventory_Official-List");
// Get specific item by id number
CamlQuery query = CamlQuery.CreateAllItemsQuery();
ListItemCollection items = recordsList.GetItems(query);
context.Load(items);
context.ExecuteQuery();
Console.WriteLine("Number of items: " + items.Count);
foreach (ListItem listItem in items)
{
Console.WriteLine(listItem["HostName"]);
if (listItem["HostName"].ToString() == "myserverhostname")
{
listItem["ActiveFlag"] = "Decommissioned";
Console.WriteLine("This Happened");
}
}
}
}