10/09/2015

SharePoint Saturday Cincinnati - SharePoint 2013 Search Results Customization

 

SharePoint Saturday Cincinnati is almost here! In fact… it's tomorrow. I thought I'd do something a little different this time and put out a little teaser on my topic. To be fair though… there's 19 other cool topics planned for Saturday, just click here to see the schedule.  Register NOW!   http://bit.ly/1DAprtv

 

So a bit about my presentation…

SharePoint 2013 Search Results Customization

Let's start with a problem… Our users can't find a certain kind of document; for example, PowerPoint presentations about our R&D projects. And when they find them, they don't know which ones are highly confidential, and more than once they have shared them with the wrong people.

And then a solution…

  • Create Site Columns for consistent metadata and to support Managed Property searches such as"ResearchGroup=aviation".
  • Configure the search schema to support friendly property names and the ability to search using "<" and ">" on dates and numbers.
  • Create a Content Type to ensure document classification and to collect important metadata.
  • Create a Display Template to add useful information to the search results, and display our Governance policies for R&D documents. ("Warning… confidential content. Do not share!")
  • Create a Result Type to map the Content Type to the Display Template.
  • Create a user friendly and governance friendly search results page.

All in an hour! 

 

See you there!

 

.

10/08/2015

SharePoint Column Validation Examples

Update 11/2/2015… added "Date must be the first day of the month" and "Date must be the last day of the month".
The following applies to SharePoint 2007, 2010 and 2013.

Column Validation

SharePoint does not include column types for phone numbers or part numbers, nor does it include support for Regular Expressions to test for character patterns. It does support Excel style functions that we can use to create useful column validation formulas.
Below you will find column validation examples for:
  • OR
  • AND
  • Length (LEN)
  • Pattern matching using SEARCH and FIND
  • Date testing

General Validation Formula Rules:

  • Formula must return True or False.
  • Column validations can only be added to Single Line of Text, Number, Choice (Drop-Down menu or Radio buttons, but not Checkboxes), Currency and Date and Time columns.
  • Expressions are generally Excel compatible, but not all Excel functions can be used.
  • Field names without special symbols can be entered as is or in square brackets
          = Price * [Qty]  > 100
  • Field namess with spaces or symbols must be enclosed in square brackets
          =OR( [Sales Region] = 1, [Sales Region] = 1)
  • The text comparisons are not case sensitive.
          =OR( status = "a", status="c")     is true for either "A" or "a" or "C" or "c".
  • In a column validation the formula cannot refer to another column.
  • In a list / library validation the formula can refer to other columns in the same item.

Examples using "OR":

The OR function accepts two or more Boolean tests that each return True or False. OR returns True if any one of the tests is True.
=OR(YourFieldName="A",YourFieldName="C",YourFieldName="E")
=OR(State="OH", State="IN", State="KY", State="MI")
=OR(Qty=5, Qty=10, Qty=20)

Examples using "AND":

The AND function accepts two or more Boolean tests that each return True or False. AND returns True if all of the tests are True.
=AND(YourFieldName>"A", YourFieldName<"M")     YourFieldName value must be between A and M.
=AND(Qty>5, Qty<100, Qty<>47)      Qty must be between 5 and 100, but not 47.

Examples using "LEN":

As an example, if your part numbers are always 9 characters long:
    =LEN(YourFieldName) = 9
If the part numbers can be 9 or 12 characters long:
    =OR( LEN(YourFieldName) = 9, LEN(YourFieldName) = 12 )

Examples for Pattern Matching

The SEARCH function:  (online help)
  • Matches a pattern using "*" and "?". "*" equals zero more characters and "?" equals exactly one character.
  • To match an asterisks or question mark character prefix the symbols with "~". 
    Example: "a~?b?c" matches "a?bxc" but not "axbxc". 
  • An "*" is assumed to be appended to the end of the match pattern. To limit the length use the AND and LEN functions.
  • The comparison is not case sensitive.
  • If there is a match, the function returns the position of the match. If the every character is to be matched you would typically test for "=1" or maybe ">0". 
  • If there is no match, the function returns ERROR, therefore it must be wrapped inside of an ISERROR function. As we will have a match if there is no error, the ISERROR must be wrapped inside of a NOT function. (online help for ISERROR)
Examples:
Must start with an "a" or "A" and the third character must be a "c" or "C":
   =NOT(ISERROR( SEARCH("A?C",YourFieldName)=1 ))
   Matches: abc   AbC  aXc  a6c aBcDEF
   Does not match:   bbb   abb  ac  a
Match a phone number pattern of xxx-xxx-xxxx: (note: user could type letters or digits or type extra characters.)
   =NOT(ISERROR( SEARCH("???-???-????",YourFieldName)=1 ))
   Matches: 123-123-1234    aaa-aaa-aaaa   123-123-12344444
Match a phone number pattern of xxx-xxx-xxxx and limit the length:
   =AND( NOT(ISERROR(SEARCH("???-???-????",YourFieldName,1))), LEN(YourFieldName)=12 )
   Matches: 123-123-1234
   Does not match: 123-123-12345

Match a phone number and make sure only digits have been used:
The first example here is not a true pattern match. It just extracts the characters we think should be digits and tries to multiply them by any number. If that fails, then one or more of the characters is not a number. (online help for CONCATENATE and MID)
=NOT(ISERROR(1*CONCATENATE(MID(YourFieldName,1,3),MID(YourFieldName,5,3),MID(YourFieldName,9,4))))
   Matches: 123-123-1234    123x123x1234   123-123-1234xxxxx
   Does not match: abc-123-1234
The second example combines the earlier pattern match with a numeric test:
   =AND(NOT(ISERROR(SEARCH("???-???-????",YourFieldName,1))),LEN(YourFieldName)=12, NOT(ISERROR(1*CONCATENATE(MID(YourFieldName,1,3),MID(YourFieldName,5,3),MID(YourFieldName,9,4)))))

The FIND Function:  (online help)
The FIND function is similar to the SEARCH function with two differences;
  • FIND is case sensitive.
  • FIND does not support wild cards.

Examples Using Dates

You can create rules to limit date ranges by using the TODAY() function or the DATEVALUE() function.
Date must be in the future:
    =YourFieldName>TODAY()
Date must be in the future by "x" days:
    =YourFieldName>TODAY() + 3I.e. If today is the 7th, then valid dates start on the 11th.
Test against a particular date:  (online help for DATEVALUE)
    =YourFieldName>datevalue("1/1/2015")
Date must be between now and the end of the current year:  (online help for YEAR)
    =YourFieldName < DATEVALUE( "12/31/" & YEAR(TODAY()) )This example calculates a DATEVALUE by building a string to represent a future date.
Date must be within the next 30 days:
    =AND(YourFieldName >= TODAY(),YourFieldName <= TODAY()+30)
Date must be a Monday:   (1 = Sunday, 2 = Monday, 3 = Tuesday, …)   (online help for WEEKDAY)
    =WEEKDAY(YourFieldName)=2
Date must be the last day of the month:
=DATE(YEAR(yourDateColumn),MONTH(yourDateColumn),DAY(yourDateColumn))=DATE(YEAR(yourDateColumn),MONTH(yourDateColumn)+1,0)
Date must be the first day of the month:
=DATE(YEAR(yourDateColumn),MONTH(yourDateColumn),DAY(yourDateColumn))=DATE(YEAR(yourDateColumn),MONTH(yourDateColumn),1)
Note: Some of the more "fun" Excel date functions like WEEKNUM, NETWORKDAYS and EOMONTH are not supported in SharePoint.

Not so useful tests!   Smile

Value must be greater than PI.  (3.14159265358979 more or less…)
    =YourFieldName > PI()
And some square roots:
    =YourFieldName > SQRT(2)
And of course you need a little trig:
    =TAN(RADIANS(YourFieldName)) > 1

.

9/28/2015

SharePoint: Who can't you hide things from?

 

You just created a new subsite. You broke inheritance. You removed all of the inherited permissions. You gave only three people access.

Can anyone else see this site?

Yup…

  • Your Site Collection Administrator.
  • People granted Web Application level "super user" permission policies by the server administrators. These roles are often called "Auditors" and "Super Administrators".
  • Server administrators who have granted themselves "super user" permissions.
  • Any administrator using the farm service account. (Never a best practice.)
  • Any one who your team members have "Shared" with!  (see below)
  • The SQL Database Administrator. (we never directly query the tables… right?)

 

Site Collection Administrators

When a new Site Collection is created the server administrator can assign people to two roles named Primary Owner and Secondary Owner. These two users can see and change everything in site collection, unless some permission has been denied by Web Application level user policies.

These two Site Collection Administrators can add as many other people to the list of Site Collection Administrators as they like. Only the Primary and Secondary will receive site alert emails, all of these admins have Full Control over everything in the Site Collection. For more interesting things about these extra admins, see: http://techtrainingnotes.blogspot.com/2012/12/fun-and-games-with-site-collection.html.

 

Web Application Level "Super User" Permission Policies

Server administrators can define Web Application level policies and broadly give or remove permissions. These policies overrule anything done at the Site Collection or subsite levels. Here's a few examples:

  • Remove the "Create Subsites" permission from all users.
  • Remove the "Manage Lists" permission from everyone in the Active Directory Sales Managers group.
  • Make a user an "Auditor" with rights to see everything in the entire Web Application. Yes, everything, including permissions and everything in the Site Settings page.
  • Make a user a "Super Administrator" with the ability to change anything in the Site Collection, and even run in "stealth mode" with all changes listed as "by System Account".

 

Team Member Sharing – Members are security admins???

In SharePoint 2013 Online, users given the "Edit" permission level can share the site or anything in any list or library in the site where they have that permission level. All they have to do is click one of the many "Share" buttons or links. This one should really scare you! All they have to do is click the Share at the top of the page, and they have shared the entire site without site owner approval. If they click Share on a document or list item, then they have broken inheritance on that item, and then shared it!  The same user in SharePoint on-premises is only creating an "access request". See how to hide the share buttons here: http://techtrainingnotes.blogspot.com/2015/08/hiding-evil-sharepoint-2013-share.html

A bit odd, while the user with the "Edit" permission can "share" a full site or a single list item, then cannot share a list or library. If they guess the URL to "Permissions for this document library" they get "access denied".

SharePoint Online/Office 365 vs. On Premises:

  On Premises Online
Member clicks the site level Share button Creates an "access request" – site owner needs to approve Adds new user to the Members group with usually has the Edit permission level
Member clicks the list or library item Share button Creates an "access request" – site owner needs to approve. If approved, breaks inheritance and adds permissions for the new user. Breaks inheritance and adds permissions for the new user.
Member guesses the URL to the People and Groups page… Can only see the list of users in the groups. Can remove users from groups!

So… Consider editing the "Edit" permission level and removing the "Manage Lists" permission!

 

 

 

.

9/20/2015

SharePoint Saturday Cincinnati… Boo!

If you don't put this in your calendar right now… ScarePoint Saturday is going to sneak right past you!

image

SharePoint Saturday Cincinnati is a FREE one day conference. The event is open to the public and is your FREE chance to immerse yourself in the SharePoint platform! Saturday October 10th , 2015 8am-6pm.

FREE one day event

Come learn from the
SharePoint EXPERTS

Register Online http://bit.ly/1DAprtv

Sponsor Raffle & Prizes following
Event

Follow us on Twitter
@spscincinnati  #spscincy

SharePoint Saturday Cincinnati is dedicated to educating and engaging members of the local SharePoint community. SharePoint Saturday Cincinnati draws upon the expertise of local and international SharePoint IT professionals, business experts, developers, architects, and users who donate their time to share real world experiences, lessons learned, best practices and general knowledge with fellow SharePoint enthusiasts.

Speakers: Ajay Iyer, Bill Crider, Brian T. Jackett, Chris McNulty, Daniel Glenn, Gina Montgomery, Heather Newman, Ivan Sanders, JD Wade, John Ramminger, Liz Sundet, Mark Rackley, Michelle Caldwell, Mike Smith, Patrick Tucker, Paul Stork, Ricardo Wilkins, Robert Bogue, Roger Sears, Ryan Dennis, Scott Brewster, Sean McDonough, Seb Matthews, Shila Nagarsenker, Simeon Cathey, Toby McGrail

SHARONVILLE CONVENTION CENTER
11355 Chester Rd, Cincinnati, OH 45246
http://www.spsevents.org/city/cinci/cinci2015/home
October 10th , 2015 8am-6pm

 

A big THANK YOU to all our Sponsors. Without you this event would not be possible.
http://www.spsevents.org/city/cinci/cinci2015/sponsors

image

 

 

.

Upload a File to SharePoint Using PowerShell

 

A while back I posted an article on downloading files from SharePoint using PowerShell (see here) that generated a few questions about uploading files. So… here's a few uploading scripts. Don't stop here though, there are many other examples on the web. Google/Bing is your friend!

 

An Upload with Metadata Script

This script not only uploads files, but lets you add metadata.

# Set a few variables
$file = "C:\test\myTestFile.txt"
$TTNwebUrl = "http://server/sites/yoursite"
$library = "Team Documents"
$overWriteExisting = $True #or add new version if versioning enabled

# do a little SharePoint setup
$web = Get-SPWeb $TTNwebUrl
$files = $web.GetFolder($library).Files
$fileNameForLibrary = $file.Substring($file.LastIndexOf("\")+1) 

# read the file
$data = Get-ChildItem $file

# add any needed metadata
$metadata = @{ "Project ID" = "A-200"; "Region" = "North" }

# or if no metadata needed: $metadata = @{}

# do the upload (the following is one line)
$newfile = $files.Add($library + "/" + $fileNameForLibrary, $data.OpenRead(), $metadata, $overWriteExisting)

 

And if you are a "one liner" PowerShell scripter:

(Get-SPWeb "http://server/sites/yoursite").GetFolder("Team Documents").Files.Add("Team Documents/myTestFile.txt", (Get-ChildItem "C:\test\myTestFile.txt").OpenRead(), $True)

And with metadata:
(Get-SPWeb "http://server/sites/yoursite").GetFolder("Team Documents").Files.Add("Team Documents/myTestFile.txt", (Get-ChildItem "C:\test\myTestFile.txt").OpenRead(), @{ "Project ID" = "A-200"; "Region" = "North" }, $True)

 

Upload an Attachment with a New List Item

I generally recommend linking from a list item to a file in a library, but if you want to add attachments to a list item, here's a sample script:

# Set a few variables
  $TTNweb = Get-SPWeb "http://yourServer/sites/yourSite";
  $list = $TTNweb.lists["yourListName"];
  $filePath = "C:\SampleDocs\yourSampleFile.JPG";

# Create a new list item:
  $item = $list.items.Add(); 
  $item["Title"] = "Test Title";
  # set any addition metadata 
  $item.Update();

# Upload the file:
  $bytes = [System.IO.File]::ReadAllBytes($filePath);
  $item.Attachments.Add([System.IO.Path]::GetFileName($filePath), $bytes);
  $item.Update();

 

 

Looking for a PowerShell course for SharePoint administrators and auditors?

SharePoint 2010 and 2013 Auditing and Site Content Administration using PowerShell

https://www.microsoft.com/en-us/learning/course.aspx?cid=55095A

Or you can attend my class in Cincinnati (locally or remotely)!
http://www.maxtrain.com/Classes/ClassInfo.aspx?Id=119394

.

9/08/2015

New SharePoint 2013 Search for Power Users Class

 

I'm very pleased to announce my latest Courseware Marketplace course! 55141AC SharePoint 2013 Search for Power Users. While the class has not shown up yet on the Microsoft Learning site, it should be here shortly. MCTs can download it today at https://shop.courseware-marketplace.com. You can attend it soon at Microsoft training centers around the world.

If you can't find the class near you, you can attend the class in Cincinnati or remotely at MAX.

SharePoint Search Class 1200

 

Oh, don't forget the administrators! We have a SharePoint 2013 search class just for them: 55122AC Microsoft SharePoint 2013 Search Administration. If you can't find the class near you, you can attend the class in Cincinnati or remotely at MAX.

SharePoint-Search-Class-Administrator-1200

 

.

8/18/2015

Cincinnati PowerShell User Group Meeting

 

Register here: (free!) http://www.meetup.com/TechLife-Cincinnati/events/224705451/

Cincinnati PowerShell Users group – August Meeting

When: August 27th
Where: Max Technical Training
Mason, OH

PS C:\> Get-PSUG | where {$_.City -eq Cincinnati}

The Cincinnati PowerShell user group is back and under new management!  Last meeting was great with Ed Wilson as our presenter, I hope you all got as fired up about scripting as we did!

Come join us as we dive into….

Version Control?  That's for Developers, not Admins!!

Does your version control look like this?!?!?

We'll cover different ways to approach source control with PowerShell, why we as System Administrators need it, and why the idea of "infrastructure-as-code" is getting so much traction these days.

 

Sponsor!

SAPIEN Technologies will be sponsoring the Cincinnati PowerShell User Group meeting and will be supplying the pizza!

.

8/16/2015

They just can't leave anything alone! "App" now is "Add-in"???

 

Just as they have gotten everyone to call everything an "app", they have to change it again. Lists = apps, libraries = apps, web parts = app parts… everything was to be an app. Now everything is a "add-in"?

  • "SharePoint apps" are not SharePoint Add-ins.
  • "SharePoint app parts" are now "SharePoint add-in parts"

But strangely…

  • The SharePoint "app launcher" and the "My Apps" page are keeping their old names.

 

Everybody say "Add-In"! Smile

https://msdn.microsoft.com/EN-US/library/office/fp179930.aspx

The name "apps for SharePoint" is changing to "SharePoint Add-ins". During the transition, the documentation and the UI of some SharePoint products and Visual Studio tools might still use the term "apps for SharePoint".

Also see:  https://msdn.microsoft.com/EN-US/library/office/fp161507.aspx#bk_newname

 

 

So… what is an "App"?

List? Libraries?  Not too sure anymore…

Oh well…

.

8/07/2015

Hiding the Evil SharePoint 2013 Share Buttons!

 

SharePoint introduced Share buttons to make it easy for users to quickly share a site, folder or document. This introduced several administration, security and governance problems for administrators. Mostly because the act of sharing a document breaks inheritance on the file. Whether this is "evil" or not depends on the way you need to use SharePoint. 

Here's a sample flow:

  • We have a library for 100 sales documents. Currently the Sales Managers group and five other users have access to the library and its contents.
  • Someone clicks the Share button on a document.
    • If the user is not an owner and does not have the Manage Lists permission, then a request is added to the Site Owners. Site Owners, if they ever discover the request, can approve or reject it.
  • Inheritance is broken on the document. Existing permissions are copied to the file. The user is added to the document's permissions list.
  • Now the fun begins…
    • A new user or group is given permissions to the library.
    • They only see 99 documents! (The missing document has unique permissions and no longer inherits permissions from the library.)

After inheritance is broken you have to remember to manage the permissions of each individual broken inheritance document. Now think about 50 libraries, each with where the Share button has been clicked on a 1000 documents. Job security at the minimum!

 

Just how many Share buttons are there?  
(Let me count the ways…)

The Share the site button:

   image

The Share a document button in the "QCB" (Quick Control Block?) bar:

   image

The Share a document button in the FILES ribbon :

   image

The Share a document button in the "…" pop out:

   image

The Share a document link in the "… …" menu:

   image

The INVITE PEOPLE button in create a new folder:

   image

The Invite People button in the Shared With dialog box:

   image

Did I miss any?

(I started on this article a few times, but each time I found yet another Share button!)

 

Disabling using Views

You can hide the Share button that's just above the library by switching to any other view style than"Default". This also hides all of the other links in the "QCB" (Quick Control Block?) bar.

image

The Share button will be grayed out in the FILE ribbon if you select a Style other than Default and Shaded, or disable "Tabular View - Allow individual item checkboxes".

Disadvantages? These styles do not display a checkbox, even if "Tabular View - Allow individual item checkboxes" is checked. Without the checkbox most of the options in the FILE ribbon are disabled.And… this approach only hides one of the Share buttons.

 

Disabling the Share buttons using CSS

The easiest way, at least until Microsoft gives us an option to turn them off, is to add CSS to the Master Page. Some of the buttons has convenient IDs while some can be found using a class. While you could merge all of the selectors into one line, I broke them out so you could choose which Share features you would like to hide or keep.

In my project I uploaded the CSS file to the Site Assets library. You could place the CSS file in any library where your users have at least read access, or in the layouts folder on the server. You would then link to the file something like this:

<link rel="stylesheet" type="text/css" 
href="https://yourServer/sites/yourSite/SiteAssets/nosharebuttons.css"></link>

Or maybe:

<link rel="stylesheet" type="text/css" href="/_layouts/nosharebuttons.css"></link>

 

The CSS:

/* CSS to hide the various Share buttons and links */
/* from TechTrainingNotes.blogspot.com             */
/* Use at your own risk. Batteries not included.   */

/* Hide Site Share button (page top right) */
#ctl00_site_share_button  {
 display:none !important;
}

/* Hide library toolbar (QCB) Share button */
.js-listview-qcbShareButton {
 display:none !important;
}

/* Hide the Share in the ... popout */
.js-callout-actionsMain span:nth-child(2) {
    display:none !important;
}


/* Hide the Share in the ... ... menu */
a[title="Share"] {
 display:none !important;
}


/* Hide the INVITE PEOPLE button in Create Folder */
#csfd_invitePeopleBtn {
 display:none !important;
}

/* Hide the Share button in the FILES ribbon */
#Ribbon\.Documents\.Share\.ShareItem-Large {
 display:none !important;
}

/* Hide the Invite People button in the Shared With dialog */
#lnkShrItem {
 display:none !important;
}

 

Here's the "one line" version:

/* CSS to hide the various Share buttons and links */
/* from TechTrainingNotes.blogspot.com             */
/* Use at your own risk. Batteries not included.   */


#ctl00_site_share_button, 
  .js-listview-qcbShareButton, 
  .js-callout-actionsMain span:nth-child(2), 
  a[title="Share"], 
  #csfd_invitePeopleBtn, 
  #Ribbon\.Documents\.Share\.ShareItem-Large, 
  #lnkShrItem 
{
 display:none !important;
}

 

.

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.