Posts

Export SharePoint Online Group Users to Excel using Powershell

Sometimes, we have a requirement to generate user reports from SharePoint groups or validate which user is added to which groups etc. If we do this activity manually, it may take forever (obviously based on the user added to group 😉).  Classic example, recently in my project i got a requirement where i need to find all the users who are added to multiple SharePoint groups. Now i have 2500 users added to my SP Groups and it is difficult to check one by one. So i generated CSV/Excel for each group and added a vlookup in excel and got my report. Below is the Powershell script, which helps to generate CSV file based on group name.  Note: All the input variables are mentioned in Green Color, Please update before executing this script. $aClient = [ System.Reflection.Assembly ]:: LoadWithPartialName( "Microsoft.SharePoint.Client" ) $aClientRuntime = [ System.Reflection.Assembly ]:: LoadWithPartialName( "Microsoft.SharePoint.Client.Runtime" )   Function Get-UserInfo

SharePoint Modern Sites

Image
In 2016, MS announced a revolutionary change in SharePoint, the change which was capable enough to attract people towards SP, the change which was very lightweight and easy to provision, the change which was mobile first, the change which was for the more open source rather than traditional server-side scripting. And the change was, MS came up with a new concept i.e. MODERN SITES. The very next thing which came in everyone’s mind, how these modern sites are different from classic SharePoint sites. Apart from above mentioned, here is a couple of difference which would make sense why. SharePoint Modern sites are “NoScript” enabled, that means there are few operations which can’t be possible when “NoScript” is enabled, like Cannot save site/Library as a template, Solution Gallery/Theme Gallery/Help Settings/Sandbox solutions not available in site settings, etc. Whenever modern sites are created, by default they are having awesome look and feel, and this new UI supports mos

C# Call SharePoint Web API from Server Object Model

In my last blog  SharePoint 2013 Create and Host Web Service . I have explained how to create SharePoint Web Service. So we need to consume that service. We can consume that service from JSOM as well as SSOM. Here I am explaining how we can consume web service from C# code(SSOM). So first of all we need to define same entity for getting data, Which we had used in operation contract of service. So below is an example of entity. a. Entity in Service Contract     [DataContract]     public class ModuleDetails     {         [DataMember]         public string ID { get; set; }         [DataMember]         public string ModuleName { get; set; }         [DataMember]         public string AppName { get; set; }     } b. Entity where we will consume that service     public class ModuleDetails     {         public string ID { get; set; }         public string ModuleName { get; set; }         public string AppName { get; set; }     } 1. If request type is Get                        

SharePoint 2013 Create and Host Web Service

Image
In this post we will discuss about how we can create WCF/Web service in SharePoint environment. Here you can get step by step instruction to create web service. This web service can be used to get data from share point. This service can return output in json and xml format. this service can be used in client side code as well as server side code. Suppose that there is a requirement say you want to perform same action from multiple platforms or multiple applications, So in such scenarios you can go with service. Its too simple to create and implementation is same as what we are doing in C# code. In WCF services hosting is always a challenge. But in SharePoint web service we can host on existing web application. So there is no need to put extra efforts to host SharePoint web service.  Below is the step to step instruction to create SharePoint Web Service. 1. Open visual studio with Run as administrator 2. Create new solution and select SharePoint 2013 - Empty Project  3. Pro

PowerShell Set Property Bag to SharePoint

Sometimes we want to set some configuration or wants to hard code :) some values in a solution. For the same we have some several ways and Property Bag is one of them.  Below is the PowerShell script to set property bag clear Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue  Add-PSSnapin Microsoft.SharePoint.Powershell $farm=Get-SPFarm $propKey = " KeyName " $propValue = " Value " if($farm.Properties.Containskey($propKey)) {     $farm.Properties.Remove($propKey) } $farm.Properties[$propKey] = $propValue $farm.Update() We have set property bag value. But now how we can access the same from our solution. So below is the code to get property bag values by key.                SPFarm farm = SPFarm.Local;                 string propertyBagKey= " KeyName ";                 string propertyBagValue= string.Empty;                 if (farm != null )                 {                     if (farm.Properti

ASP.NET: Confirm PostBack OnClientClick Button

ASP.Net Button: <asp:Button ID="btnSubmit" runat="server" class="unrulyBtn" Text="Submit" OnClientClick="if ( ! btnSubmitonClickEvent()) return false;" OnClick="btnSubmit_Click" CausesValidation="True" /> Java Script Method: function btnSubmitonClickEvent() {         if (confirm('Once submitted, Flight Report for this sector cannot be edited.')) {          // We can't use disable here because if we make that button as disabled, In that case OnClick will not work.          // $('[id$=btnSubmit]').attr("disabled", "disabled");                          $('[id$=btnSubmit]').attr("style", "display:none");             return true;         }         else {             //   $('[id$=btnSubmit]').removeAttr('disabled');             $('[id$=btnSubmit]').attr("style", "display:block");        

SharePoint 2013: Working with User Profiles using CSOM

As we all know SharePoint 2013 provides strong support to client api. In this post we will talk about access user profile properties using client api. So now in SharePoint 2013 we can directly query to user profile and get all the user profile properties what we required. References which we need to provide <script src="/_layouts/15/jquery-1.9.0.min.js"></script> < script   src = "/_layouts/15/SP.Runtime.js" ></ script > <script src="/_layouts/15/SP.js"></script> <script src="/_layouts/15/SP.UserProfiles.js"></script> 1. Get User Profile Properties for Current User        $(document).ready(function(){        // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs. SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'SP.UserProfiles.js'); }); var userProfileProperties; function loadUserData(){ //Get Current Context v