Posts

Showing posts from January, 2015

Powershell: Recusively Check In and Publish files in a SharePoint Document Library

I have combined the scripts from Paul King ( here ) and Brijendra Gautam ( here ) to create my own version of the script. Function CheckInAndPublishFolderItemsRecusively( [Microsoft.SharePoint.SPFolder] $folder ) {     # Create query object     $query = New-Object Microsoft.SharePoint.SPQuery     $query.Folder = $folder     # Get SPWeb object     $web = $folder.ParentWeb     # Get SPList     $list = $web.Lists[$folder.ParentListId]     # Get a collection of items in the specified $folder     $itemCollection = $list.GetItems($query)     # Iterate through each item in the $folder     foreach ($item in $itemCollection)     {         # If the item is a folder         if ($item.Folder -ne $null)         {             # Call the Get-Items function recursively for the found sub-solder             CheckInAndPublishFolderItemsRecusively $item.Folder         }         else         { if ($item.File.Level -ne "Published") {            if ($item.File.

SharePoint Online: How do I extract list changes with PowerShell?

Import-Module 'C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell' -DisableNameChecking $loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") $webUrl = "https://mysite.sharepoint.com/" $username = "richard.leeman@mydomain.onmicrosoft.com" $password = Read-Host -Prompt "Password for $username" -AsSecureString $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $web = $ctx.Web $webs = $web.Webs $lists = $web.Lists $ctx.Load($lists) $ctx.Load($webs) $ctx.Load($web) $ctx.ExecuteQuery() $list = $lists| Where-Object { $_.Title -eq "My Documents"} $dt = Get-Date $dtUTC = $dt.ToUniversalTime() $changeQ

SharePoint Online: How do I configure the Site Collection Audit Settings from CSOM?

My current project requires that the Site Collection Audit Settings be provisioned with every new OneDrive for Business site. The problem is that there is not existing API (in CSOM or PowerShell) to set these values. Problem? Yes. Insurmountable? No. I was pointed in the direction of this  fantastic blog. The basic idea behind the code is to replicate the 'POST' event that is created by using the UI. The code is magnificent but (as is continually stressed in the video) is not supported by Microsoft.  This does not mean that is will not work, it just means that should the name of the underlying fields change, the code will fail unceremoniously. Anyway, back to the solution.  Firstly, enable the 'Reporting' Site Collection feature. The feature Guid is "7094bd89-2cfe-490a-8c7e-fbace37b4a34" and should be activated as a FARM level feature Secondly, here is my add-in code to the set values. using System.Globalization; namespace Contoso.Remote