Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.
Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.

Blog

What’s in that patch? November 2016

NOTE – PDF format updated to include both SharePoint 2013 and 2016 notes.

 

Ever wondered what fixes are inside of a given CU?   Please see attached PDF with full detail. I wanted a new format for easy reading.   Show management and make the business case for why downtime should be taken to apply CUs.  Also posted at http://sharepointupdates.com/

If you found this helpful, please leave a comment.   

shades_smile_thumb_thumb_thumb_thumb[2]

 

Download

What’s in that patch – Nov 2016.PDF

PowerShell – Create SharePoint Alert remotely (CSOM)

I want to migrate user alerts to Office 365 from SharePoint 2013 on-prem and was surprised to learn there is no client side API for creating Alerts.   Not SOAP, not REST, nothing but the web browser ASPX web form GUI.

So I took Fiddler and inspected the HTTP POST traffic when you click “OK” on the SharePoint “SubNew.aspx” page in the browser.   Lots of great detail!    You can see all the ASPX web form controls and internal values.   Clicking the “OK” button posts that event back to the server side Dot Net for processing with Request Digest, ViewState, and lots of cool stuff.

So …. could we simulate sending that same HTTP traffic?   From somewhere else?    Like PowerShell??    That’d be awesome!

 

Below is the working concept. PowerShell function with a handful of sample calls. Immediate alert, Daily, Weekly scheduled, etc. With various recipients and filters. Enjoy! 

shades_smile

 

Screenshots

image
image
image
image
image
image

 

Code  (CreateSPAlert.ps1)

Function CreateSPAlert($webURL, $listID, $userLogin, $userDisplayName, $alertTitle, $changeType, $sendAlertsFor, $whenToSend, $whenToSendDay, $whenToSendTime) {
    <#
    ASPNet WebForm Input Values
    $changeType
    -1 All changes
     1 New items are added
     2 Existing items are modified
     4 Items are deleted
    $sendAlertsFor
    0 'Anything changes'
    1 ''
    2 ''
    3 ''
    $whenToSend
    0 immediate
    1 daily
    2 weekly
    $whenToSendDay
    0 Sunday
    1 Monday
    2 Tuesday
    3 Wednesday
    4 Thursday
    5 Friday
    6 Saturday
    $whenToSendTime
    12:00 AM
    1:00 AM
    ..
    11:00 AM
    12:00 PM
    1:00 PM
    ..
    11:00 PM
    #>
    # Convert parameters
    switch ($sendAlertsFor) {
        '1' {$sendAlertsFor=''}
        '2' {$sendAlertsFor=''}
        '3' {$sendAlertsFor=''}
        default {$sendAlertsFor='Anything changes'}
    }
    # List Scope
    $url = "$webURL/_layouts/15/SubNew.aspx?List=$listID"
    $fields = Invoke-WebRequest -Uri $url -UseDefaultCredentials -UseBasicParsing  | select -ExpandProperty inputfields | select name, value
    # HTTP POST Body WeBforms
    $postParams = @{
    'MSOWebPartPage_PostbackSource'='';
    'MSOTlPn_SelectedWpId'='';
    'MSOTlPn_View'='0';
    'MSOTlPn_ShowSettings'='False';
    'MSOGallery_SelectedLibrary'='';
    'MSOGallery_FilterString'='';
    'MSOTlPn_Button'='none';
    '__LASTFOCUS'='';
    '__EVENTTARGET'='ctl00$PlaceHolderMain$ctl01$RptControls$BtnCreateAlert';
    '__EVENTARGUMENT'='';
    'MSOSPWebPartManager_DisplayModeName'='Browse';
    'MSOSPWebPartManager_ExitingDesignMode'='false';
    'MSOWebPartPage_Shared'='';
    'MSOLayout_LayoutChanges'='';
    'MSOLayout_InDesignMode'='';
    'MSOSPWebPartManager_OldDisplayModeName'='Browse';
    'MSOSPWebPartManager_StartWebPartEditingName'='false';
    'MSOSPWebPartManager_EndWebPartEditing'='false';
    '_maintainWorkspaceScrollPosition'='741';
    '__REQUESTDIGEST' = ($fields|? {$_.Name -eq '__REQUESTDIGEST'}).Value;
    '__VIEWSTATE'=($fields|? {$_.Name -eq '__VIEWSTATE'}).Value;
    '__SCROLLPOSITIONX'='0';
    '__SCROLLPOSITIONY'='0';
    '__EVENTVALIDATION'=($fields|? {$_.Name -eq '__EVENTVALIDATION'}).Value;
    'ctl00$PlaceHolderMain$ctl03$ctl01$TextTitle'=$alertTitle;
    'ctl00$PlaceHolderMain$ctl04$ctl01$clientPeoplePicker'="[{""Key"":""$userLogin"",""DisplayText"":""$userDisplayName"",""IsResolved"":true,""Description"":""$userLogin"",""EntityType"":"""",""EntityGroupName"":"""",""HierarchyIdentifier"":null,""EntityData"":{""SPUserID"":""1"",""AccountName"":""$userLogin"",""PrincipalType"":""User""},""MultipleMatches"":[],""ProviderName"":"""",""ProviderDisplayName"":"""",""Resolved"":true}]";
    'ctl00$PlaceHolderMain$ctl05$ctl02$rdoDC'='rdo_EmailDC';
    'ctl00$PlaceHolderMain$ctl06$ctl01$RadioBtnEventType'=$changeType;
    'ctl00$PlaceHolderMain$ctl07$ctl02$RadioBtnAlertFilter'=$sendAlertsFor;
    'ctl00$PlaceHolderMain$hdnAlwaysNotify'='False';
    'ctl00$PlaceHolderMain$ctl08$ctl02$RadioBtnAlertFreq'=$whenToSend}
	
	# Append if needed
	if ($whenToSendDay) {
		$postParams.Add('ctl00$PlaceHolderMain$ctl08$ctl03$DdlWeekDay',$whenToSendDay);
	}
	if ($whenToSendTime) {
		$postParams.Add('ctl00$PlaceHolderMain$ctl08$ctl03$DdlHour',$whenToSendTime);
	}
    # Execute HTTP
    $response = Invoke-WebRequest -Uri $url -WebSession RequestForm -Method POST -Body $postParams -ContentType 'application/x-www-form-urlencoded' -UseBasicParsing
}
# Main
$start = Get-Date
# Create SP alerts
CreateSPAlert 'http://sharepoint/sites/test' '%7B0D568A08%2DD7AA%2D405B%2DADE1%2DF324216C0272%7D' 'i:0#.w|company\\jsmith' 'John Smith' 'Documents' '-1' 'Anything changes' '0'
CreateSPAlert 'http://sharepoint/sites/test' '%7B0D568A08%2DD7AA%2D405B%2DADE1%2DF324216C0272%7D' 'i:0#.w|company\\jsmith' 'John Smith' 'Documents' '4' 'Anything changes' '0'
CreateSPAlert 'http://sharepoint/sites/test' '%7B0D568A08%2DD7AA%2D405B%2DADE1%2DF324216C0272%7D' 'i:0#.w|company\\jsmith' 'John Smith' 'Daily-Documents' '4' 'Anything changes' '1' '0' '7:00 PM'
CreateSPAlert 'http://sharepoint/sites/test' '%7B0D568A08%2DD7AA%2D405B%2DADE1%2DF324216C0272%7D' 'i:0#.w|company\\jsmith' 'John Smith' 'Weekly-Documents' '4' 'Anything changes' '2' '5' '5:00 PM'
# Run duration
$end = (Get-Date) - $start
$ms = $end.TotalMilliseconds
"$ms MS duration"

 

 

References

How to install Office Online Server for SharePoint 2016 (OOS)

Recently I wanted to create a SharePoint 2016 lab environment.   With Excel Services moving out of the SharePoint 2016 product, we now need to plan for an instance of OOS.   Below are the steps I followed and screenshots of the process.

Cheers! 

shades_smile

Steps

  1. Install Windows Server 2012 R2 (en_windows_server_2012_r2_with_update_x64_dvd_6052708.iso)
    1. NOTE – Windows Server 2016 seems to be missing Ink and Handwriting Support.
  2. Run PowerShell to install IIS
# Always
Import-Module ServerManager
# from https://docs.microsoft.com/en-us/officeonlineserver/deploy-office-online-server
# Win 2012 R2
Add-WindowsFeature Web-Server,Web-Mgmt-Tools,Web-Mgmt-Console,Web-WebServer,Web-Common-Http,Web-Default-Doc,Web-Static-Content,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression,Web-Security,Web-Filtering,Web-Windows-Auth,Web-App-Dev,Web-Net-Ext45,Web-Asp-Net45,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Includes,InkandHandwritingServices,NET-Framework-Features,NET-Framework-Core,NET-HTTP-Activation,NET-Non-HTTP-Activ,NET-WCF-HTTP-Activation45,Windows-Identity-Foundation,Server-Media-Foundation
# Win 2016
Add-WindowsFeature Web-Server,Web-Mgmt-Tools,Web-Mgmt-Console,Web-WebServer,Web-Common-Http,Web-Default-Doc,Web-Static-Content,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression,Web-Security,Web-Filtering,Web-Windows-Auth,Web-App-Dev,Web-Net-Ext45,Web-Asp-Net45,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Includes,NET-Framework-Features,NET-Framework-45-Features,NET-Framework-Core,NET-Framework-45-Core,NET-HTTP-Activation,NET-Non-HTTP-Activ,NET-WCF-HTTP-Activation45,Windows-Identity-Foundation,Server-Media-Foundation
  1. Install Windows Identity Foundation
  2. Install Ink and Hand Writing Services
  3. Get latest Windows Updates
  4. Generate Self Signed Certificate
    1. Start > Run > INETMGR > Server > Server Certificates > Generate self signed certificate with “OOS” Friendly Name
    2. Start > Run > INETMGR > Server > Server Certificates > Export “OOS” to PFX file
      with password

    3. Start > Run > CERTLM.MSC > add Local Machine certificates > import PFX to “Personal” folder
    4. Start > Run > CERTLM.MSC > add Local Machine certificates > import PFX to “Trusted Root Certificate Authorities” folder
  5. Install Office Online Server (en_office_online_server_may_2016_x64_dvd_8484396.iso)
  6. Create new OOS farm
md "D:\Logs\ULS"
md "D:\ProgramData\Microsoft\OfficeWebApps\Working\d"
md "D:\ProgramData\Microsoft\OfficeWebApps\Working\waccache"
New-OfficeWebAppsFarm -InternalURL "https://offlineonline" -CertificateName "OOS" -EditingEnabled -LogLocation "D:\Logs\ULS" -CacheLocation "D:\ProgramData\Microsoft\OfficeWebApps\Working\d" -RenderingLocalCacheLocation "D:\ProgramData\Microsoft\OfficeWebApps\Working\waccache"

Screenshots

image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image

Error

  • Resolves the PowerShell error “New-OfficeWebAppsFarm : It does not appear that this machine is part of an Office Online Server farm.”

References

What’s in that patch? October 2016

NOTE – PDF format updated to include both SharePoint 2013 and 2016 notes.

 

Ever wondered what fixes are inside of a given CU?   Please see attached PDF with full detail. I wanted a new format for easy reading.   Show management and make the business case for why downtime should be taken to apply CUs.  Also posted at http://sharepointupdates.com/

If you found this helpful, please leave a comment.   

shades_smile_thumb_thumb_thumb_thumb[2]

 

Download

What’s in that patch – Oct 2016.PDF

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲