working on it ...

Filters

Explore Public Snippets

Sort by

Found 785 snippets matching: sharepoint

    public by skaggej  336496  3  6  0

    SharePoint 2010 - Disable the "New" icon for newly added content

    This is another easy and useful one; I find it helpful when I'm recording content and adding it as I'm going. I don't really want the word "New" next to some things and not next to others. The finalized recordings look better if that's never there. Here's the simple PowerShell script that you can run per web application to disable the "New" icon
    $webApp = Get-SPWebApplication http://sharepoint2010
    $webApp.DaysToShowNewIndicator = "0"
    $webApp.Update()

    public by skaggej  237899  1  6  0

    SharePoint 2010 - Bulk Upload Solution Packages

    When migrating a SharePoint environment from 2007 to 2010, don't forget about your solution packages! You can extract them from the SharePoint 2007 Solution Store, then use this script to upload them all to SharePoint 2010 in seconds!
    $solutions = Get-ChildItem -Path "C:\downloads\Exported Solution Packages"
    $solutions | ForEach-Object {add-spsolution -literalpath "C:\Exported Solution Packages\$_"}

    public by skaggej  230822  1  6  0

    SharePoint 2010 - View Resource Measures for Sandboxed Solutions

    Ever wonder exactly what "300 points" means for you sandboxed solutions' resource quota in SharePoint 2010? Run the following PowerShell script in the SharePoint 2010 Management Shell and you'll be able to see it for yourself.
    $resourceMeasures = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local.ResourceMeasures
    $resourceMeasures | Select Name, ResourcesPerPoint
    

    public by skaggej  219437  2  6  0

    SharePoint 2010 - List All SharePoint PowerShell Cmdlets

    This is a quick and easy way to view and save all of the PowerShell cmdlets that are available for SharePoint. It's quite useful to have this list of commands handy. Once you know which command you want to run, then it's time to learn how to use it with Get-Help.
    Get-Command -Module Microsoft.SharePoint.PowerShell | Select Name >> C:\AllSharePointPowerShellCmdlets.txt
    

    public by skaggej  4560  6  6  1

    SharePoint 2010 - Delete All Content Types in a Specific Content Type Group

    This script will delete all content types within the specific content type group for the specified site collection. Prior to running this script, you must be sure that your content types are not being referenced anywhere.
    $url = "http://www.sharepointnerd.com"  <# Replace this URL with your own. #>
    $site = get-spsite $url
    $rootWeb = $site.OpenWeb()
    $myContentTypes = $rootWeb.ContentTypes | Where-Object{$_.Group -eq "SharePointNerd Content Types"} <# Replace this content type group with your own. #>
    $myContentTypes | foreach-object{$_.Delete()}

    public by skaggej  2712  1  6  0

    SharePoint 2010 - Export Farm Solutions

    This is especially useful when you want to be sure that you have a backup of the current solution packages before you overwrite them with updated ones. I run this before every production deployment to ensure that I have a way to revert back to the old "version" of my solutions.
    $path = "C:\downloads\Exported Solution Packages"
    (Get-SPFarm).Solutions | ForEach-Object{$var = $path + "\" + $_.Name; $_.SolutionFile.SaveAs($var)}

    public by skaggej  2276  0  6  0

    SharePoint 2010 - Enable the Developer Dashboard

    Use this PowerShell script to set the DisplayMode property of the developer dashboard in SharePoint 2010 to 'OnDemand.' Acceptable values include: 'Off,' 'On,' and 'OnDemand.' This script assumes you're running the SharePoint 2010 Management Shell on a SharePoint 2010 server.
    $dd = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings
    $dd.DisplayLevel = 'OnDemand' <-- Possible values are:  On, Off, or OnDemand.  The OnDemand option is preferred.
    $dd.TraceEnabled = $true
    $dd.Update()

    public by msdn  167397  0  7  0

    GetStorefrontUrl: Returns the URL (string) of the SharePoint storefront for a given app. It uses the license to extract the corresponding AssetId

    Returns the URL (string) of the SharePoint storefront for a given app. It uses the license to extract the corresponding AssetId A license object that has already been verified by the Store web service The URL of the web where the app is installed. Get this from SP tokens The URL of the current page (so users can return to it from the storefr
    using LicenseSPAppSampleWeb.LicenseVerificationService;
    using Microsoft.SharePoint.Client;
    using System;
    using System.Web;
    using System.Xml;
    
    /// <summary>
    /// Returns the URL (string) of the SharePoint storefront for a given app. It uses the license to extract the corresponding AssetId
    /// </summary>
    /// <param name="verifiedLicense">A license object that has already been verified by the Store web service</param>
    /// <param name="hostWebUrl">The URL of the web where the app is installed. Get this from SP tokens</param>
    /// <param name="currentPageUrl">The URL of the current page (so users can return to it from the storefront); must be same domain as hostWeb</param>
    /// <param name="appName">The title of the breadcrum that storefront will display on the back link</param>
    public static string GetStorefrontUrl(VerifyEntitlementTokenResponse verifiedLicense, string hostWebUrl, string currentPageUrl, string appName)
    {
        String storeTemplateString = "{0}/_layouts/15/storefront.aspx?source={1}&sname={2}&#vw=AppDetailsView,app={3},clg=0,cm=en-US";
    
        //Note: If you are using the hardcoded token provided in the sample this URL will always point to the Cheezburgers app. 
        return String.Format(storeTemplateString, hostWebUrl, currentPageUrl, appName,verifiedLicense.AssetId);
         
    }

    public by msdn  89577  0  6  0

    GetCamlQuery: Returns CamlQuery for fetching ListItems in the specified SharePoint Views

    Returns CamlQuery for fetching ListItems in the specified SharePoint Views Name of the View CamlQuery for the View
    using System;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Microsoft.SharePoint.Phone.Application;
    using Microsoft.SharePoint.Client;
    using System.Collections.Generic;
    
    /// <summary>
    /// Provies access to ViewXml for SharePoint Views.
    /// </summary>
    static Dictionary<string, string> ViewXmls = new Dictionary<string, string>()
            {   
                //{"View1", @"<View><Query><OrderBy><FieldRef Name='ID' /></OrderBy></Query><RowLimit>30</RowLimit><ViewFields>{0}</ViewFields></View>"}
                {"View1", @"<View><Query>{0}</Query><RowLimit>30</RowLimit><ViewFields>{1}</ViewFields></View>"}
            };
    /// <summary>
    /// Provides access to ViewFields which should be fetched for every View. Since, all the Views uses the same Display,Edit and NewForms the ViewFields got 
    /// to be the same for all of them.
    /// </summary>
    static string ViewFields = @"<FieldRef Name='Title'/><FieldRef Name='Unit_x0020_Price'/><FieldRef Name='Quantity'/><FieldRef Name='Order_x0020_Value'/><FieldRef Name='Order_x0020_Date'/><FieldRef Name='Status'/><FieldRef Name='Customer'/>";
    
    /// <summary>
    /// Returns CamlQuery for fetching ListItems in the specified SharePoint Views
    /// </summary>
    /// <param name="viewName">Name of the View</param>
    /// <returns>CamlQuery for the View</returns>
    public static CamlQuery GetCamlQuery(string viewName, string customerName)
    {
        string queryClause = string.Empty;
    
        // Create appropriate Query Clause, depending on customerName parameter.
        if (string.IsNullOrWhiteSpace(customerName))
        {
            queryClause = "<OrderBy><FieldRef Name='ID' /></OrderBy>";
        }
        else
        {
            queryClause = string.Format("<Where><Eq><FieldRef Name='Customer' /><Value Type='Text'>{0}</Value></Eq></Where>", customerName);
        }
    
        // Add Query Clause and ViewFields to ViewXml.
        string viewXml = ViewXmls[viewName];
        viewXml = string.Format(viewXml, queryClause, ViewFields);
    
        return new CamlQuery { ViewXml = viewXml };
    }

    public by msdn  133171  1  6  0

    GetS2SClientContextWithWindowsIdentity: Retrieves an S2S client context with an access token signed by the application's private certificate on behalf of the specified WindowsIdentity and intended for application at the targetApplicationUri...

    Retrieves an S2S client context with an access token signed by the application's private certificate on behalf of the specified WindowsIdentity and intended for application at the targetApplicationUri using the targetRealm. If no Realm is specified in web.config, an auth challenge will be issued to the targetApplicationUri to discover it.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Collections.ObjectModel;
    using System.Globalization;
    using System.IdentityModel.Selectors;
    using System.IdentityModel.Tokens;
    using System.IO;
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    using System.Security.Principal;
    using System.ServiceModel;
    using System.ServiceModel.Channels;
    using System.Text;
    using System.Web.Configuration;
    using System.Web.Script.Serialization;
    using Microsoft.IdentityModel;
    using Microsoft.IdentityModel.S2S.Protocols.OAuth2;
    using Microsoft.IdentityModel.S2S.Tokens;
    using Microsoft.SharePoint.Client;
    using Microsoft.SharePoint.Client.EventReceivers;
    
    private static readonly string Realm = WebConfigurationManager.AppSettings.Get("Realm");
    
    /// <summary>
    /// Retrieves an S2S client context with an access token signed by the application's private certificate on 
    /// behalf of the specified WindowsIdentity and intended for application at the targetApplicationUri using the 
    /// targetRealm. If no Realm is specified in web.config, an auth challenge will be issued to the 
    /// targetApplicationUri to discover it.
    /// </summary>
    /// <param name="targetApplicationUri">Url of the target SharePoint site</param>
    /// <param name="identity">Windows identity of the user on whose behalf to create the access token</param>
    /// <returns>A ClientContext using an access token with an audience of the target application</returns>
    public static ClientContext GetS2SClientContextWithWindowsIdentity(
        Uri targetApplicationUri,
        WindowsIdentity identity)
    {
        string realm = string.IsNullOrEmpty(Realm) ? GetRealmFromTargetUrl(targetApplicationUri) : Realm;
    
        JsonWebTokenClaim[] claims = identity != null ? GetClaimsWithWindowsIdentity(identity) : null;
    
        string accessToken = GetS2SAccessTokenWithClaims(targetApplicationUri.Authority, realm, claims);
    
        return GetClientContextWithAccessToken(targetApplicationUri.ToString(), accessToken);
    }
    • Public Snippets
    • Channels Snippets