kwizcom banner advertisement

SharePoint Online: Update Created By / Modified By, Created At / Modified At Field values using PowerShell CSOM

2:36 PM    , ,
At times, you may have to create list items or set existing item's metadata fields such as Created by, Modified by, Created at, Modified values to a specific user - time stamp. Say, You are importing or migrating data from a network file share to SharePoint online and you want to keep these metadata as same as the source content. Because, SharePoint doesn't let you to set these values from web user interface, we've to use PowerShell. Here is my PowerShell script to change the details of who created an item, modified it and when they created and modified it. This script sets system fields (created, created by, modified, modified by) for a specific item in the list/library. Set the values in variables section appropriately and run the script. PowerShell script to update Created by, Modified By, Created at, Modified at field values: This PowerShell script sets item's metadata field values in SharePoint online #Load SharePoint CSOM Assemblies Add-Type -Path "C:
SharePoint Online: Update Created By / Modified By, Created At / Modified At Field values using PowerShell CSOM SharePoint Online: Update Created By / Modified By, Created At / Modified At Field values using PowerShell CSOM Reviewed by Salaudeen Rajack on 2:36 PM Rating: 5

SharePoint Online: PowerShell to Send Email

5:02 PM    , , ,
We can send emails from SharePoint online, either with SPUtility's SendEmail function or with PowerShell cmdlet Send-MailMessage . Here are examples in both the cases: PowerShell to Send Email in SharePoint Online: Here is how to send an E-mail from SharePoint Online using PowerShell Client Side Object Model (CSOM) script. Import-Module Microsoft.Online.SharePoint.Powershell -DisableNameChecking #Config Parameters $AdminSiteURL = "https://crescent-admin.sharepoint.com/" $EmailFrom ="SPAdmin@crescent.com" $EmailTo = "Salaudeen.Rajack@crescent.com" $Subject ="SharePoint Online Storage Report" #Setup Credentials and connect $Cred = Get-Credential Connect-SPOService -Url $AdminSiteURL -Credential $Cred #Get Storage Usage of All Site collections $SiteStorage = Get-SPOSite -Detailed | Select Url, StorageUsageCurrent #Setup the site context for SPUtility SendEmail $Ctx =
SharePoint Online: PowerShell to Send Email SharePoint Online: PowerShell to Send Email Reviewed by Salaudeen Rajack on 5:02 PM Rating: 5

Copy Group Membership Permissions of a User in SharePoint using PowerShell

8:17 PM    , , , , , ,
Requirement: Copy SharePoint Group Memberships of one user to another user Solution: You can copy group memberships of one user to another user to have identical SharePoint Permissions for a SharePoint Site. Here is the PowerShell Script: PowerShell Script to copy Group Memberships from One user to another: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Configuration Parameters $SiteURL="http://intranet.crescent.com" $SourceUserID="i:0#.w|Crescent\Salaudeen" $TargetUserID="Crescent\Opera" #Get the web $web = Get-SPWeb $SiteURL #Get All group membershipss of the source user $UserGroups = Get-SPUser $SourceUserID -web $SiteURL | Select -ExpandProperty Groups #Get the Target User $TargetUser = $web.EnsureUser($TargetUserID) #Add target user to each group Foreach($GroupName in $UserGroups) { Write-Host "Adding User to the Group:"$GroupName #Get the Group $Group = $Web.SiteGroups[$GroupName
Copy Group Membership Permissions of a User in SharePoint using PowerShell Copy Group Membership Permissions of a User in SharePoint using PowerShell Reviewed by Salaudeen Rajack on 8:17 PM Rating: 5

SharePoint Online: How to Change Site Logo using PowerShell?

5:06 PM    , , ,
Changing logo is a common requirement when it comes to branding SharePoint online sites. How to change Logo in SharePoint Online: Changing logo in sharepoint online is a matter of few clicks. To add logo to sharepoint online, follow these steps Login as a site Administrator to your SharePoint Online site. Click on Settings gear >> Select Site Settings >> On Site settings page, Click on "Title, description, and logo" link. That takes you to a page where you can set Logo for the site. you can use either a logo from your computer, or any existing logo from your SharePoint site (Even any existing image from the Internet too). Click on "From Computer" link >> Browse and upload your logo file. Once you upload, the logo file gets saved into "Site Assets" Library of the site. As soon as you upload a image for logo, You'll find the new logo reflected immediately in the top left hand side of the site. Optionally, you can enter descri
SharePoint Online: How to Change Site Logo using PowerShell? SharePoint Online: How to Change Site Logo using PowerShell? Reviewed by Salaudeen Rajack on 5:06 PM Rating: 5

SharePoint Online: Add Currency Column to List using PowerShell

9:10 PM    , ,
Requirement: Add Currency Column to SharePoint Online List How to Create Currency Field in SharePoint Online List? Browse to your SharePoint Online site and Navigate to the target list in which you want to add Currency column. Under the List tab, click on "Create Column" button in the ribbon. Provide the Name to your new column, specify the type as "Currency" Scroll down  Fill other optional values such as Minimum and Maximum values, decimal places, Currency format, etc and Click on "OK" to create Currency field in SharePoint Online list. PowerShell to Add Currency Column to List in SharePoint Online #Load SharePoint CSOM Assemblies 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" #Custom function to add column t
SharePoint Online: Add Currency Column to List using PowerShell SharePoint Online: Add Currency Column to List using PowerShell Reviewed by Salaudeen Rajack on 9:10 PM Rating: 5

SharePoint Online: How to Get List in PowerShell

8:12 PM    , , ,
SharePoint Online: Get List from PowerShell Here is the PowerShell to Get SharePoint Online List Import-Module Microsoft.Online.SharePoint.Powershell -DisableNameChecking #Config Variables for Site URL, List Name $SiteURL= "https://crescent.sharepoint.com/sites/sales/" $ListName="Sales Contacts" #Setup Credentials to connect $Cred = Get-Credential $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password) Try { #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Cred #powershell sharepoint online get list $List = $Ctx.Web.Lists.GetByTitle($ListName) $Ctx.Load($List) $Ctx.ExecuteQuery() Write-host "Total Number of Items in the List:"$List.ItemCount } Catch [Exception] { Write-host $_.Exception.Message -f Red } This script gets the given list and number of items from the list. Related Post: SharePoint On
SharePoint Online: How to Get List in PowerShell SharePoint Online: How to Get List in PowerShell Reviewed by Salaudeen Rajack on 8:12 PM Rating: 5

Import-Module: The specified module 'Microsoft.Online.SharePoint.Powershell' was not loaded because no valid module file was found in any module directory.

5:43 PM    , , ,
Problem: When trying to add PowerShell module for SharePoint online, using " Import-Module Microsoft.Online.SharePoint.PowerShell", it resulted in below error in both PowerShell console and in PowerShell ISE. "Import-Module : The specified module 'Microsoft.Online.SharePoint.Powershell' was not loaded because no valid module file was found in any module directory." Solution:  Make sure you have SharePoint Online Management Shell installed on the machine you are getting the error. You can download and install SharePoint Online Management Shell from: https://www.microsoft.com/en-us/download/details.aspx?id=35588 You can check installed modules by: Get-Module -listavailable If you are getting this error in SharePoint Online Management Shell, Make sure you removed x86 version of SharePoint online management shell from your computer, and Try download and Re-Install 64bit version! Try running: Set-ExecutionPolicy Unrestrict once Run PowerShell or P
Import-Module: The specified module 'Microsoft.Online.SharePoint.Powershell' was not loaded because no valid module file was found in any module directory. Import-Module: The specified module 'Microsoft.Online.SharePoint.Powershell' was not loaded because no valid module file was found in any module directory. Reviewed by Salaudeen Rajack on 5:43 PM Rating: 5

SharePoint Online: Create Permission Level using PowerShell

8:41 PM    , , ,
Requirement:  Create a new permission level in SharePoint online site collection for contribute without delete permissions. SharePoint Permission levels are set of actions user can perform in SharePoint, packaged as a group to make permission management easier. So, Instead of providing individual permissions to users and groups, you pick a permission level and assign it to the new user. (or even Add the user to a group which has a specific permission level associated). Contribute without delete permission level is often required in real world scenarios. Lets say, You want your users to be able to add files to the library but not delete files from the library. To achieve, we can simply copy the "Contribute" permission level and take off "Delete Items" permission from it! How to create a permission level in SharePoint Online? To create new permission level in SharePoint Online, Follow these steps:   Go to the Site Settings >> Click on Site Permissions
SharePoint Online: Create Permission Level using PowerShell SharePoint Online: Create Permission Level using PowerShell Reviewed by Salaudeen Rajack on 8:41 PM Rating: 5

SharePoint Online: PowerShell to Create Document Library

6:03 PM    , , ,
Requirement: Create a document library in SharePoint online using PowerShell SharePoint Online: PowerShell to Create Document Library: How to Create document library in SharePoint online using PowerShell? #Load SharePoint CSOM Assemblies 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" #Variables for Processing $SiteURL = "https://Crescent.sharepoint.com/Sites/Sales" $LoginName ="Salaudeen@Crescent.OnMicrosoft.com" $LoginPassword ="Password" #Get the Client Context $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) #supply Login Credentials $SecurePWD = ConvertTo-SecureString $LoginPassword –asplaintext –force $Credential = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Log
SharePoint Online: PowerShell to Create Document Library SharePoint Online: PowerShell to Create Document Library Reviewed by Salaudeen Rajack on 6:03 PM Rating: 5

SharePoint Online: Import Terms to Term Set from CSV using PowerShell

1:58 AM    , , , ,
Requirement: Import terms to term set in SharePoint Online from a CSV file using PowerShell. Here is my CSV file with list of Terms for a Term set called "Job Title" SharePoint Online Import Terms to Term Set using PowerShell:  #Load SharePoint CSOM Assemblies 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" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll" #Variables for Processing $AdminURL = "https://crescent-admin.sharepoint.com/" $TermGroupName= "People" $TermSetName="Job Title" $CSVFile ="C:\Temp\ImportTerms.csv" $TermHeaderInCSV ="JobTitle" Try { #Get Credentials to connect $Cr
SharePoint Online: Import Terms to Term Set from CSV using PowerShell SharePoint Online: Import Terms to Term Set from CSV using PowerShell Reviewed by Salaudeen Rajack on 1:58 AM Rating: 5

Fix for "Cannot Connect to Database Master at SQL Server at Server Name. The Database might not exist, or the current user does not have permission to connect to it" SharePoint Error

7:30 PM    , , , , ,
Problem: When trying to create a new SharePoint farm using PowerShell, the SharePoint 2016 management Shell gave an error message: New-SPConfigurationDatabase : Cannot connect to database master at SQL server at <SQL-Server-Alias>. The database might not exist, or the current user does not have permission to connect to it. Tried using SharePoint products configuration wizard as well and got the same issue! Troubleshooting Checklist: Check the permissions for the Setup account which you are using to run the wizard or PowerShell. Make sure the setup account is granted with "DB_Creator" and "Security_Admin" Server Roles. In case of Named instance, it should be "Server\InstanceName". If it is SQL Alias, make sure the alias is properly configured and should be accessible from SharePoint Server. Verify if the SQL Server Alias is created for both 32 and 64-bit! How to Create SQL Server Alias for SharePoint Check if the SQL Server Service i
Fix for "Cannot Connect to Database Master at SQL Server at Server Name. The Database might not exist, or the current user does not have permission to connect to it" SharePoint Error Fix for "Cannot Connect to Database Master at SQL Server at Server Name. The Database might not exist, or the current user does not have permission to connect to it" SharePoint Error Reviewed by Salaudeen Rajack on 7:30 PM Rating: 5

How to Create New Target Application ID in Secure Store Service for BCS in SharePoint 2016?

8:08 PM    , , , ,
When you want to consume external data in SharePoint, such as data from your other business applications, you can use Business Connectivity Services (BCS) together with Secure Store Service. The external data source that you can connect to is called a Secure Store Target Application. BCS makes it possible for you to set up a connection to the Target Application, and the Secure Store enables you to manage the credentials that are required by the external data source Before proceeding, You have created and configured Secure store service application and generated the master key from SharePoint 2013/2016 Central Administration site, isn't it? If not, Refer: How to Configure Secure Store Service Application in SharePoint 2016 - Step by Step or Create SharePoint 2013 Secure Store Service Application using PowerShell Now you are all set to create new Target Applications and use in SharePoint. Here you go! How to Create New Target Application ID? Here are the steps to Ad
How to Create New Target Application ID in Secure Store Service for BCS in SharePoint 2016? How to Create New Target Application ID in Secure Store Service for BCS in SharePoint 2016? Reviewed by Salaudeen Rajack on 8:08 PM Rating: 5

SharePoint Online: How to Hide a List or Library using PowerShell?

6:35 PM    , , , , , ,
Requirement : Hide a list or library from SharePoint Online site. SharePoint Online: Hide Document Library using PowerShell There are many ways to hide a SharePoint online list. Here is the PowerShell CSOM script to create hidden lists in SharePoint online.   #Load SharePoint CSOM Assemblies 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" #Config Parameters $SiteURL= "https://crescent.sharepoint.com/sites/sales/" $LibraryName="ProjectConfig" #Setup Credentials to connect $Cred = Get-Credential $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password) Try { #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $C
SharePoint Online: How to Hide a List or Library using PowerShell? SharePoint Online: How to Hide a List or Library using PowerShell? Reviewed by Salaudeen Rajack on 6:35 PM Rating: 5

SharePoint Online: Bulk Add Terms, Term Sets and Term Groups from CSV using PowerShell

7:42 PM    , , , , ,
Requirement: Bulk Add Terms, Term Sets and Term Groups from a CSV File into SharePoint Online term store. Here is the format and data to import: PowerShell Script to Bulk Add Terms, Term Sets and Groups to SharePoint Online Term Store: ##Load SharePoint CSOM Assemblies 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" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll" #Variables for Processing $AdminURL = "https://crescent-admin.sharepoint.com/" Try { #Get Credentials to connect $Cred = Get-Credential $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password) #Setup the con
SharePoint Online: Bulk Add Terms, Term Sets and Term Groups from CSV using PowerShell SharePoint Online: Bulk Add Terms, Term Sets and Term Groups from CSV using PowerShell Reviewed by Salaudeen Rajack on 7:42 PM Rating: 5

SharePoint Online: Create Term in Term Store using Powershell

7:25 PM    , , , ,
Requirement: Create a Term in SharePoint Online Term Store. How to Create a Term in SharePoint Online Term Store? To create a new term in SharePoint online term store, follow these steps: Navigate to your SharePoint admin center site. (E.g. https://yourdomain-admin.sharepoint.com) Click the "term store" link on the left navigation menu. Expand and locate the Term set in which you want to add a new Term. Click on the little arrow in the Term set Header >> Click on "Create Term" option Start typing your new term, Hit enter to complete creating the term. PowerShell to Create New Term in SharePoint Online Term Store: #Load SharePoint CSOM Assemblies 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" Add-Type -Path "C:\
SharePoint Online: Create Term in Term Store using Powershell SharePoint Online: Create Term in Term Store using Powershell Reviewed by Salaudeen Rajack on 7:25 PM Rating: 5
Powered by Blogger.