PowerShell to get totals of Excel SpreadSheet Column and Post to Sharepoint List

This is a simple little script that I added on to a previous script to get Computer Bitlocker Report and Post the totals to Sharepoint 2010 List

# Check if the Sharepoint Snapin is loaded already, and load if not
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
Add-PSSnapin Microsoft.SharePoint.PowerShell

$reportcsv = Import-CSV q:\.csv

$totalTrue = $reportcsv | Where-Object {$_. -eq "TRUE"} | Measure-Object HasBitlockerRecoveryKey -line
$totalFalse = $reportcsv | Where-Object {$_. -eq "FALSE"} | Measure-Object HasBitlockerRecoveryKey -line

#Setting our variables, Site name, List name, file to import and Caml
$spWeb = Get-SPWeb -Identity "https://"
$Summarylist = $spWeb.Lists[""]

#adds Report to SharePoint List
$item = $list.Items.Add();
$item["True"] = $totalTrue.lines;
$item["False"] = $totalFalse.lines;

Of course you should replace the that I put in above with your info, but you get the idea.


%d bloggers like this: