Administration Development on Tuesday, 8 August 2017 at 2.00pm by Ryan Ball
I’m posting this as a useful reminder. It outlines how alerts can now be created via CSOM.
New SharePoint CSOM version released for SharePoint Online – February 2017
The included code sample is in C#, but I’ve translated it to PowerShell – which suits my administrative needs better.
[System.Reflection.Assembly]::LoadWithPartialName( "Microsoft.SharePoint.Client" ) | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName( "Microsoft.SharePoint.Client.Runtime" ) | Out-Null
# Set variables
$path = "C:\Temp\Usernames.txt"
$url = "https://xxxxxx.sharepoint.com/sites/help"
$list = "My List"
$title = "$list (Auto-subscribed)"
# Prompt the administrator to log in
$credential = Get-Credential -Credential $null
# Create a connection to SharePoint Online
$context = New-Object Microsoft.SharePoint.Client.ClientContext( $url )
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials( $credential.UserName, $credential.Password )
# Retrieve the targeted web
$web = $context.Web
$context.Load( $web )
# Loop through the provided usernames and create a new alert for each one
$usernames = Get-Content -Path $path
foreach ( $username in $usernames )
$user = $context.Web.EnsureUser( $username )
$alert = New-Object Microsoft.SharePoint.Client.AlertCreationInformation
$alert.List = $context.Web.Lists.GetByTitle( $list )
$alert.AlertFrequency = [Microsoft.SharePoint.Client.AlertFrequency]::Daily
$alert.AlertTime = ( Get-Date ).AddDays( 1 )
$alert.AlertType = [Microsoft.SharePoint.Client.AlertType]::List
$alert.AlwaysNotify = $false
$alert.DeliveryChannels = [Microsoft.SharePoint.Client.AlertDeliveryChannel]::Email
$alert.Status = [Microsoft.SharePoint.Client.AlertStatus]::On
$alert.Title = $title
$alert.User = $user
$alert.EventType = [Microsoft.SharePoint.Client.AlertEventType]::All
$alert.Filter = "1"
$guid = $user.Alerts.Add( $alert )
Administration on Thursday, 8 June 2017 at 3.01pm by Ryan Ball
To remove all data from a table and reset its primary key you can normally run the following SQL command:
TRUNCATE TABLE MyTable;
However, if you try this on a table with one or more foreign keys, you’re going to get an error message. Normally, the way around this is to drop the constraints, truncate the table, and recreate the constraints – which is a lot of fuss.
The following does the same job, but without the fuss.
DELETE FROM MyTable;
DBCC CHECKIDENT (MyTable, RESEED, 0);
Administration on Friday, 7 April 2017 at 1.36pm by Cornflower Design
No able to start the User Profile Synchronization Service within SharePoint 2013? Ensure you’re logged into Central Administration using the same account as you’ve specified to run the service and click the Start action.
Administration on Thursday, 6 April 2017 at 9.23am by Cornflower Design
For PowerShell scripts that need to access resources (e.g. a site within SharePoint) and be run as scheduled tasks, I will normally use an encrypted password…
Read-Host "Enter Password" -AsSecureString | ConvertFrom-SecureString | Out-File "$PSScriptRoot\Password.txt"
… and then refer to it within my script.
$username = "email@example.com"
$password = Get-Content "$PSScriptRoot\Password.txt"
$securePassword = $password | ConvertTo-SecureString
$credential = New-Object System.Management.Automation.PSCredential( $username, $securePassword )
This <a href="https://blog.kloud.com.au/2016/04/21/using-saved-credentials-securely-in-powershell-scripts/">blog post by Kloud</a> covers some this technique in greater detail.
Administration on Tuesday, 4 April 2017 at 2.22pm by Cornflower Design
By default, IIS7 will restrict uploaded greater than 30mb. To overcome this, the following settings can be added to the web.config file within your web application.
<requestLimits maxAllowedContentLength="157286400" />
The value for the
maxAllowedContentLength attribute should be specified in bytes ( MB to Bytes Conversion).
Error message when you visit a Web site that is hosted on a server that is running Internet Information Services 7.0: “HTTP Error 404.13 – CONTENT_LENGTH_TOO_LARGE”.
It can also be helpful to define the
maxRequestLength and executionTimeout attributes. <system.web>
<customErrors defaultRedirect="~/Error.aspx" mode="On">
<error statusCode="404" redirect="~/Error.aspx" />
<globalization culture="en-GB" uiCulture="en-GB" />
<sessionState timeout="60" cookieless="AutoDetect" />
<httpRuntime executionTimeout="300" maxRequestLength="150000" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
Administration on Monday, 27 March 2017 at 10.06am by Cornflower Design
Recently, despite ensuring the SSL certificates within
Internet Information Services (IIS) were updated ahead of their expiry, I fell foul of the hidden certificate within SharePoint 2013’s Security Token Service. In my defence, this is a certificate not mentioned within IIS or the Central Administration site. Its one of those lovely settings that can only be seen, analysed, and amended via PowerShell commands. Once you know/remember its there, its relatively straight forward to update. $path = "C:\certificate.pfx"
$password = "thepassword"
$certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $path, $password, 20
Set-SPSecurityTokenServiceConfig -ImportSigningCertificate $certificate
certutil -addstore -enterprise -f -v root $certificate
net stop SPTimerV4
net start SPTimerV4
Replace the STS certificate for the on-premises environment
Administration on Friday, 15 July 2016 at 12.08pm by Ryan Ball
Another note to self. When wanting a SharePoint workflow to send an email to the members of a specific SharePoint group:
ensure that the group has at least Read access to the site
within the group settings, check that “Who can view the membership of this group?” is set to Everyone
Administration on Wednesday, 17 February 2016 at 3.54pm by Ryan Ball
While waiting for a purchase order for
Sharegate to be approved, I needed to quickly migrate content of an old SharePoint 2010 list to our new SharePoint 2013 farm. Out of the box this isn’t straight forward, and Microsoft recommend a complete backup, move and upgrade approach for the entire content database. Time-wise, this wasn’t an option and seemed overkill for a single list.
In the past I’ve experimented by writing a PowerShell script to export the list’s content to a .CSV file and it’s attachments into folders, and then another script to suck it back into the destination site.
Before heading down that route again, I searched for a different approach and found the
Fast & Cheap method documented by Vlad Catrinescu.
It basically involves:
Exporting the list from SharePoint 2010 via the Backup and Restore option within Central Administration.
Changing the extension of the resulting files from .cmp to .cab, and extracting their contents.
Amending the versions stated within the SystemData.xml file from 14.0.x.x to 15.0.x.x
Repackaging them back into a .cab file via
CapPack. Changing the extension from .cab back to .cmp
Importing the list into SharePoint 2013 via PowerShell.
Import-SPWeb -Identity http://mysharepointsite -Path \\temp\SharePointList.cmp -IncludeUserSecurity -Verbose
It seems to have worked like a charm!
Administration on Wednesday, 16 September 2015 at 11.04am by Cornflower Design
Very odd. Even though I’ve been using Internet Explorer 11 and SharePoint 2013 together for some time, this morning, when I created a new Site Collection and added a Calendar, it wasn’t rendering as it should and many links were broken.
After a little research, it seems that IE11 doesn’t work out-of-the-box with SharePoint 2013 and boils down to
an inconsistency with the X-UA-Compatible meta tag.
To overcome this, I added
a new URL rewrite rule into IIS that spoofs the User Agent of the visitor’s browser, forcing the SharePoint page to be rendered correctly. No Compatibility View required.
Administration on Thursday, 30 April 2015 at 10.10am by Cornflower Design
You can use the Content Query web part within a SharePoint site without activating publishing feature (which you may want to do as activating the feature introduces and changes a lot of options):
Go to the
Web Part Gallery within an existing publishing site Export the ContentQuery.webpart file and upload it to the
Web Part Gallery of the destination site Copy the three .XSL documents (Header, ItemStyle, ContentQueryMain) from the
XSL Style Sheets folder within the Style Library and transfer them to the destination site