Showing posts with label Do and Don't do n SharePoint. Show all posts
Showing posts with label Do and Don't do n SharePoint. Show all posts

Thursday, January 7, 2021

Getting ALL users from SharePoint online tenant and set userprofile property via Powershell

Getting all user profiles within SharePoint tenant using SharePoint Online CSOM API

  • retrieve all the users in tenant (Get-MsolUser cmdlet)
  • iterate users and utilize SharePoint User Profiles CSOM API to retrieve user profile

function Get-SPOContext([string]$Url,[string]$UserName,[string]$Password)
{
   $context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
   $context.Credentials = Get-SPOCredentials -UserName $UserName -Password $Password
   return $context
}


function Get-SPOCredentials([string]$UserName,[string]$Password)
{
   $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
   return New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
}



function Print-UserProfileInfo([Microsoft.SharePoint.Client.UserProfiles.PeopleManager]$PeopleManager,[string]$AccountName){
   $ctx = $PeopleManager.Context
   $accountName = "i:0#.f|membership|" + $AccountName  #claim format  
   $userProfile = $PeopleManager.GetPropertiesFor($AccountName)
   $ctx.Load($userProfile)
   $ctx.ExecuteQuery()
   Write-Host $userProfile.PersonalUrl
}

Tuesday, December 8, 2020

SharePoint Online: How to take SharePoint Online Backup ?

 SharePoint Online: we have two types of the Service Scope.

  • Service Backup- all the content is backed up on a regular basis in the case there is corruption 
  • Deletion Backup- users will accidentally or purposely delete content. Its avaliable for 93 days only.


We can Requesting Backups from Microsoft raise the ticket.

  • backs up content every 12 hours, and take a few days to restore, so depending on the urgency for getting the data
SharePoint Online Backup


  1. we can syncing the data one drive to SharePoint or SharePoint to One drive  Bidirectional option.
  2. Timer Job to create the backup.
  3. PowerShell to copy all the data local drive

https://techcommunity.microsoft.com/t5/sharepoint/sharepoint-online-backup-strategies-for-a-cloudy-day/m-p/225418 


Tuesday, December 20, 2016

Which is the Front-end technologies for SharePoint Framework development?

Microsoft has clearly mentioned in their key notes, they are building the framework and it is related samples using KnockoutJs and ReactJs with Typescript. Since it is an open-source based development model, choosing the framework/technologies are completely our choices, based on our knowledge and requirements. Here I have listed out a few front-end technologies.
  1. Angular 1.x - https://angularjs.org/
  2. Angular 2 - https://angular.io/
  3. ReactJs - https://facebook.github.io/react/
  4. KnockoutJs - http://knockoutjs.com/
  5. Ember.Js - http://emberjs.com/
  6. Backbone.Js - http://backbonejs.org/
  7. Aurelia.io - http://aurelia.io/

Thursday, June 9, 2016

Show custom action in ribbon for only one list

Example Code:

<CustomAction ControlAssembly="CustomProject.Actions" 
                ControlClass="CustomProject.Actions" 
                ControlSrc="/_layouts/test/testPage.aspx" 
                Description="This is my custom action" 
                GroupId="MyCustomActions" 
                Id="f5bcd75e-23b9-4623-9a82-41cc7ceb10a6" 
                RegistrationId="MyMagicalList" 
                RegistrationType="List" 
                RequireSiteAdministrator="false" 
                Rights="AddListItems" 
                Sequence="1" 
                ShowInReadOnlyContentTypes="false" 
                ShowInSealedContentTypes="false" 
                Title="MyCustomAction">

EnabledScript parameter in CommandUIHandler, where you can put javascript code and check if specific page/list/view is loaded.

Example:

<CommandUIHandler 
  Command="Ribbon.ListItem.CustomGroup.Controls.BtnSayHello.Command"
  CommandAction="javascript:alert('Image ');"
  EnabledScript="javascript:
    function isEnable(){
      if(location.href.indexOf('AllItems.aspx') > 0){
        return true;
      }
      return false;
    }
    isEnable();"
/>

Saturday, July 4, 2015

Do and Don't do n SharePoint Developement ,Best practices In SharePoint 2013,2010

When creating new columns, name them without any special characters or spaces.  After the column is created, rename it with the special characters or spaces.  This way the internal name is "clean".
When you are working with DataViews, some third party controls, and custom Webparts - you must use the internal name.  The potential for confusion is enormous.
When you are adding sites and pages make sure their names don't have spaces.

URLs
When adding pages or sites to your navigation, always browse to the intended destination; this will ensure your tabs will work properly.  In fact if you compare the resulting URL after you fix a broken tab this way, you will see that the URL must be relative, not absolute.

Use the same practice of giving the relative URL instead of the absolute URL in the Content Editor Webpart or Master Pages or in any other circumstance where you are required to provide the URL.

Whenever there is a requirement to change the URL in the Master Page wherein the Mater Page has been deployed as a feature, always change the link in the Master Page which is residing inside the Feature Folder and do not use SharePoint Designer to open a Site and Change the Link.

Backup/Restore or Export/Import

Never use Back Up and Restore procedure if you are trying to restore a Site Collection which is using Collaboration Portal, instead use Export and Import.

Same applies to saving of a collaboration site as template. MS does not support this.

STSADM
Get familiar with the various stsadm.exe commands. It helps a lot and saves time.
STSADM commands has been deprecated and will not be supported in future releases of Microsoft Sharepoint Foundation 2010.

SP Designer
Avoid using SharePoint Designer to edit any page design as much as possible. This causes a lot of performance issues.

Hive older backup
Please take the backup of the 12/14 hive if you are trying to do any changes inside the 12/14 hive.

Rollback Plan

Always have the rollback plan ready whenever you are deploying anything on the web server as SharePoint is very unstable so you would never know what is causing the problem very soon.

General
Learn to use the SharePoint object model efficiently.

Make sure that you always Dispose() the SPSite and SPWeb object in the finally block of your code.

Whenever you are required to loop through something, use for loop instead of foreach loop.

Try to avoid looping as much as possible. See if the same can be achieved through CAML query or SiteData Query or by using Search Object Model which actually fires the query on the crawled results.

Even if you are looping, try to reduce the number of loops as much you can.

Modularize your code and divide them into different parts depending on their functionality. Do not write bulky code.

Always put all your functions in try-catch block.

Never do any sort of Hard-Coding in your code.

Whenever there is more than one content DB for a web application for any reasons. Make sure that all the newly created sites goes to a particular content DB only and the data should not be going randomly to all the content DB’s. You can do this by setting the limitation for the number of sites in one of the content DB where you do not want the new data to go.

Make use of time bound caching wherever you are not required to show the real time data. Also you can use caching when you’re are pulling out data from a database and showing it in your Webpart. You have to set the Sql Dependency for the same.

Using Objects in Event Receivers
Do not instantiate an SPWeb, SPSite, SPList, or SPListItem object within an event receiver. Event receivers that instantiate these objects instead of using the instances passed via the event properties can cause the following issues:

Significant additional round-trips to the database (one write operation can result in up to five additional round-trips in each event receiver).
Calls to the Update method on these instances can cause subsequent Update calls in other registered event receivers to fail.
Usage of OOB files

Do not change OOB files. OOB files can be .aspx, .ascx ,.xsl, .xml, .js,.css  etc under 14 hive directory. Changing OOB can cause huge issues which cannot be traceable and changes will be visible to all applications that are running in the farm. If you want to use OOB files for customization purpose, create new folders, make a copy of the file and have it in the new folder and customize it.
For example,
If you wanna use/customize approve.aspx, create a new folder under  1033/layouts/<application name> , copy approve.aspx from 1033/layouts/ and paste it under 1033/layouts/<application name> and then customize it.