Skip to main content

Posts

Showing posts with the label SharePoint 2019

PowerShell - CSOM code to get SharePoint Online Sites Permission Report

#sharepoint online powershell permissions report Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"          $AdminSiteURL="https://m365x067565-admin.sharepoint.com/"   #Connect to SharePoint Online Admin Write-host "Connecting to Admin Center..." -f Yellow Connect-SPOService -url $AdminSiteURL -Credential (Get-Credential) #Get each site collection and users $Sites = Get-SPOSite -Limit ALL Foreach($Site in $Sites) { $SiteURL=$Site.Url   } #To call a non-generic method Load Function Invoke-LoadMethod() {     param(             [Microsoft.SharePoint.Client.ClientObject]$Object = $(throw "Please provide a Client Object"),             [string]$PropertyName       ...

Build and Deploy a custom theme in SharePoint 2019: Using C# and Site features

Custom Theme and Branding are common to use cases and all kinds of business users like to have the personalized team and collaboration sites. today I am posting C# code that will help to build custom features for SharePoint 2019 site.   If need any assistance, I would be happy to help: kamal_pandey@outlook.com  ----------------------------- Code to build  custom features---------- using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.SharePoint; using Microsoft.SharePoint.Utilities; namespace SharePointBranding.Code {     public class BrandingManager     {         public SPWeb Web { get; set; }         public BrandingManager(SPWeb web)         {             Web = web;         }         public void SetMasterPage(stri...

Powershell Script to get all SharePoint wsp solutions

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $dirName = "C:\WSP" if (!(Test-Path -path $dirName)) { New-Item $dirName -type directory } Write-Host Exporting solutions to $dirName foreach ($solution in Get-SPSolution) {     $id = $Solution.SolutionID     $title = $Solution.Name     $filename = $Solution.SolutionFile.Name     Write-Host "Exporting ‘$title’ to …\$filename" -nonewline     try {         $solution.SolutionFile.SaveAs("$dirName\$filename")         Write-Host " – done" -foreground green     }     catch     {         Write-Host " – error : $_" -foreground red     } } Note: If need any help please reach out to me at kamal_pandey@outlook.com.  I would be very happy to help. 

Solve Missing user profile picture in SharePoint 2019

Dear All,  Below is the Powershell script that will help you solve broken profile picture issue. $mySiteNewHostURL = "http://NewMySiteHostURL" $mySiteOldHostURL = "http://OldMySiteHostURL" $mySite = Get-SPSite $mySiteNewHostUrl $SPServiceContext = Get-SPServiceContext $mySite $userProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($SPServiceContext) $userProfiles = $userProfileManager.GetEnumerator() foreach ($userProfile in $userProfiles) { #check if the picture property contain image URL, then replace it with new my site host URL if ($userProfile["PictureURL"] -ne '') { $oldImageUrl = $userProfile["PictureURL"].toString() $newImageUrl = $oldImageUrl -Replace $mySiteOldHostURL, $mySiteNewHostURL write-host "Old Image Link = " $oldImageUrl " --> New Image Link = " $newImageUrl $userProfile["PictureURL"].Value = $newImageUrl $userP...

Delete a SharePoint list Field(Column) using PowerShell

Delete a SharePoint list Field(Column) using PowerShell Hello folks, The following is a code snippet from PowerShell to completely remove or delete a field in a SharePoint list. The code uses the GUID to find the field (column). I tested this with SharePoint 2013. Approch #1 #Set-ExecutionPolicy RemoteSigned [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")    Get-PSSnapin –Registered Add-PSSnapin Microsoft.SharePoint.PowerShell  #Variables $SiteURL="xxxxxxxxx" $ListName="News" $ColumnName="WikiPlus"   #Get Internal Name of the columns $web = Get-SPWeb $SiteURL   #Get the list $list = $web.Lists.TryGetList($ListName)   if($List -ne $null) {     #Get the column      $column = $list.Fields[$ColumnName]       if($column -ne $null)     {         #Reset column properties to allow delete     ...