kwizcom banner advertisement

Copy Permissions from One SharePoint Site to Another using PowerShell

1:28 PM    , , , , ,
Requirement: Copy permissions from one site to another in SharePoint! Solution: If you want to copy one SharePoint site to another site, there is no OOTB ways! However, You can use PowerShell to copy permissions between sites. Here is my PowerShell script to copy site permissions. Copy Permissions from one site to another using PowerShell: Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue #PowerShell Function to copy permissions from one site to another Function Copy-SitePermissions() { param( $SourceWebURL, $TargetWebURL ) Try { #Set the Error Action $ErrorActionPreference = "Stop" #Get the Source and Target Webs $SourceWeb = Get-SPWeb $SourceWebURL $TargetWeb = Get-SPWeb $TargetWebURL #if permissions are Inherited in the target, Break it! if($TargetWeb.Permissions.Inherited) { #Reset the Inheritence in Target Web $TargetWeb.BreakRoleInheritance($false) } #Copy permissions from Source to Tar
Copy Permissions from One SharePoint Site to Another using PowerShell Copy Permissions from One SharePoint Site to Another using PowerShell Reviewed by Salaudeen Rajack on 1:28 PM Rating: 5

SharePoint Online: Add "Yes/No" Check Box Column to List using PowerShell

7:59 PM    , , ,
Requirement: Add Yes/No Check box column to SharePoint online list using PowerShell How to Create Yes/No Check box column in SharePoint Online List? Browse to your SharePoint Online site and Navigate to the target list in which you want to add Yes/No column. Under the List tab, click on "Create Column" button in the ribbon. Provide the Name to your new column, specify the type as "Yes/No Check box" Fill other optional values such as field description, Default Value and Click on "OK" to create Yes/No check box field in SharePoint Online list. PowerShell to Create "Yes/No" Check Box Column in SharePoint Online List: #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 fun
SharePoint Online: Add "Yes/No" Check Box Column to List using PowerShell SharePoint Online: Add "Yes/No" Check Box Column to List using PowerShell Reviewed by Salaudeen Rajack on 7:59 PM Rating: 5

SharePoint Online: Add Hyperlink or Picture Column to List using PowerShell

6:29 PM    , , ,
How to Create Hyperlink or Picture Column to List using PowerShell Browse to your SharePoint Online site and Navigate to the target list in which you want to add hyperlink or picture column. Under the List tab, click on "Create Column" button in the ribbon. Provide the Name to your new column, specify the type as "Hyperlink or Picture". Select the format of the URL as either Hyperlink or Picture from the "Format URL as" drop down. Fill other optional values such as Field description, Required and Add to default view settings.  Click on "OK" to create Hyperlink or Picture field in SharePoint Online list. PowerShell to Add Hyperlink or Picture Column to SharePoint Online List: #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\IS
SharePoint Online: Add Hyperlink or Picture Column to List using PowerShell SharePoint Online: Add Hyperlink or Picture Column to List using PowerShell Reviewed by Salaudeen Rajack on 6:29 PM Rating: 5

Customize Suitebar Text and Link in SharePoint 2016 using PowerShell

5:31 PM    , , ,
Requirement: By default, SharePoint 2016 comes with "SharePoint" as the suitebar branding text.  What if you would like to change it to something meaningful, say "Your Company Intranet"? Well, PowerShell can help to customize the branding text, Logo and URL in SharePoint 2016. PowerShell Script to change Suitebar navigation text and link: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $WebApp= Get-SPWebApplication "http://intranet.crescent.com" $WebApp.SuiteNavBrandingText = "Crescent Portal" #Blank image from Layouts folder $webapp.SuiteNavBrandingLogoUrl = "/_layouts/images/dot_ruleper.gif" $webapp.SuiteNavBrandingLogoTitle = "Crescent Logo" $webapp.SuiteNavBrandingLogoNavigationUrl = "http://portal.crescent.com" $webapp.Update() Here is the result of customized SharePoint 2016 suite bar branding using PowerShell! My another post Customizing the SharePoint 2013 suite bar bra
Customize Suitebar Text and Link in SharePoint 2016 using PowerShell Customize Suitebar Text and Link in SharePoint 2016 using PowerShell Reviewed by Salaudeen Rajack on 5:31 PM Rating: 5

SharePoint Online: Delete Site Column using Powershell

5:35 PM    , , ,
Requirement: Delete Site Column in SharePoint online using PowerShell How to delete a site column in SharePoint online? To remove a SharePoint online site column, follow these steps: Go to Site Settings by clicking Site settings gear and then "Site settings" from the menu. Click on "Site Columns" link from Web Designer Galleries group >> Select the site column to delete. Scroll down and click on "Delete" button and confirm the prompt to delete. This removes a site column in SharePoint online. SharePoint online PowerShell to delete site column : #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" #Set Variables for Site URL and Site column Title $SiteURL= "https://cresc
SharePoint Online: Delete Site Column using Powershell SharePoint Online: Delete Site Column using Powershell Reviewed by Salaudeen Rajack on 5:35 PM Rating: 5

How to Delete a SharePoint Web Application?

1:48 PM    , , ,
SharePoint Web Applications are actually an IIS Containers at top level. Each web application we create from SharePoint, creates respective site in IIS and a content database in SQL Server. To delete a SharePoint 2016 Web Application, Open SharePoint 2016 Central Administration Site Click on "Manage web applications" link under "Application Management" Select your target web application, and from the ribbon, click on Delete button. Specify whether you would like to delete the content databases and IIS web sites. Confirm the Prompt once to delete a web application in SharePoint 2013 and your web application will be deleted momentarily. This removes the specified web application from the SharePoint farm. SharePoint delete web application zone: To delete SharePoint web application extension, From SharePoint Central Administration: Click on Administration Management >> Manage Web Applications Select the web application you wish to remove the e
How to Delete a SharePoint Web Application? How to Delete a SharePoint Web Application? Reviewed by Salaudeen Rajack on 1:48 PM Rating: 5

SharePoint Online: Delete List using PowerShell CSOM

5:21 PM    , , , , ,
How to Delete a list or library in SharePoint Online? Click on Site Settings gear >> Select Site contents from the menu. On the site contents page, Hover over the list or library that you want to delete and then click the drop-down menu icon (…) On the menu that appears, click on "Remove" link and then confirm the prompt to send the list to the Recycle Bin.  Alternatively, you may remove a list or library in SharePoint online by going to list settings >> Click on "Delete this list" under Permissions and Management group. Now, lets delete list in sharepoint online using PowerShell Delete List in SharePoint Online using PowerShell: SharePoint online PowerShell to delete list #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\Mi
SharePoint Online: Delete List using PowerShell CSOM SharePoint Online: Delete List using PowerShell CSOM Reviewed by Salaudeen Rajack on 5:21 PM Rating: 5

SharePoint Online: Configure Access Request Email Settings using PowerShell

8:42 PM    , , , ,
Access request settings in SharePoint Online Access Request feature in SharePoint online allows people to request access to content that they do not have permission. It also allows members of the site to send invitations to users who have no permission. Once the invitations are sent, Site owner should approve it from Site settings >> Access requests and invitations. If you change these settings on the Site Collection level, then new sub sites doesn’t inherit. How to Set SharePoint Online Access Request Email? To configure access request email settings in SharePoint online, Go to Site Settings >> Site Permissions >> Access Requests Settings  This takes you to SharePoint online access request page >> Update access request email and hit OK to save your changes. Please note, SharePoint online access request email Site Settings must be configured at each site level. Lets see SharePoint Online PowerShell to set access request email. Set SharePoint online
SharePoint Online: Configure Access Request Email Settings using PowerShell SharePoint Online: Configure Access Request Email Settings using PowerShell Reviewed by Salaudeen Rajack on 8:42 PM Rating: 5

Get All Users and Groups in SharePoint Online Site using PowerShell-CSOM

4:43 PM    , , , , , , ,
Requirement: Get All Users and Groups Report in SharePoint Online using PowerShell-CSOM PowerShell Script to Get All Users and Groups Report in SharePoint Online: This PowerShell script gets all groups and users of each group in a SharePoint online site. #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" #Set Variables for Site URL $SiteURL= "https://crescent.sharepoint.com/sites/sales/" #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 #Get all Groups $Groups=
Get All Users and Groups in SharePoint Online Site using PowerShell-CSOM Get All Users and Groups in SharePoint Online Site using PowerShell-CSOM Reviewed by Salaudeen Rajack on 4:43 PM Rating: 5

SharePoint Online: Get Content Type ID using PowerShell-CSOM

5:24 PM    , , ,
My other article speaks on How to find the content type id in SharePoint , using SharePoint UI and PowerShell for SharePoint On-premises, This post provides script to get content type by id programmatically for SharePoint online. To get the content type ID, you can Go to List/Site Content Types >> Pick your content type >> The URL will have "Ctype" parameter with the content type ID! SharePoint Online: Get content type id using CSOM Here is the PowerShell script to get content type id in SharePoint using csom code. #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" $ContentTypeName="Crescent Project Report" #Setup C
SharePoint Online: Get Content Type ID using PowerShell-CSOM SharePoint Online: Get Content Type ID using PowerShell-CSOM Reviewed by Salaudeen Rajack on 5:24 PM Rating: 5

How to Get Content Type ID in SharePoint using PowerShell?

2:49 PM    , , , , ,
Requirement: A typical usage of Content Types is reusable metadata in SharePoint. At times, You may need to get content type id by name in order to  assign the content type to lists and libraries programmatically. Lets get content type id in SharePoint 2013 using PowerShell. How to find content type id in SharePoint List? To get content type id from SharePoint interface: Open your SharePoint List in browser >> click on "List Settings" from the List tab of the Ribbon In the List Settings page click on your target content type under "Content types" - Assuming content types are enabled already. Now, You'll see the ID of the content type in the URL.The last part is the Content Type Id. E.g. http://intranet.crescent.com/_layouts/15/ManageContentType.aspx?List=%7BEE1EA017%2DD347%2D49E6%2D9FE2%2D2CA7D1CB7B57%7D& ctype=0x01160074E6A09BFE52244F8ECB851FF74077FC Same procedure applies for Site content Types as well. Go to Site settings >> Site Con
How to Get Content Type ID in SharePoint using PowerShell? How to Get Content Type ID in SharePoint using PowerShell? Reviewed by Salaudeen Rajack on 2:49 PM Rating: 5

Get All Site Collections in a Web Applications using PowerShell

7:37 PM    , , , , , , ,
How to get all site collections of a web application in SharePoint? To get all site collections in web application, from SharePoint central Admin, follow these steps: Go to SharePoint Central Admin Site >> Application Management  Click on "View all site collections" link under Site Collections Group. Select your web application. This page lists all site collections in the selected web application. Get all site collections in web application using PowerShell: Here is the PowerShell to list all site collections in web application. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Set the Web application URL $WebAppURL="http://intranet.crescent.com" #Get the Web Application $WebApp = Get-SPWebApplication $WebAppURL #Get all Site collections from the web application $SitesCollection = $WebApp.Sites #Enumerate all site collections in the web application Foreach($Site in $SitesCollection) { #Get Site Collection
Get All Site Collections in a Web Applications using PowerShell Get All Site Collections in a Web Applications using PowerShell Reviewed by Salaudeen Rajack on 7:37 PM Rating: 5

Add-Remove User to SharePoint Multi-Valued People Picker Field using PowerShell

3:18 PM    , ,
Requirement:  We've a SharePoint list called "Projects" with 1000's of items. The list has a field called "Team Members" which allows multiple user values. We often get a requirement to either add or remove a particular user to all items or specific items filtered by other columns in the list. Solution: Adding-removing user from multiple items in a bulk can be achieved with PowerShell. Lets use PowerShell to add or remove user from SharePoint people picker (person or group) field value. PowerShell to Add new user to Person or Group Field: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Configuration parameters $SiteURL = "http://portal.crescent.com/projects/" $ListName = "Projects" $FieldName= "TeamMembers" $UserToAdd="Crescent\Sam" #Get site and List objects $web = Get-SPWeb $SiteURL $List = $web.Lists.TryGetList($ListName) #Item Ids to update $IDColl= @(4,5,7,
Add-Remove User to SharePoint Multi-Valued People Picker Field using PowerShell Add-Remove User to SharePoint Multi-Valued People Picker Field using PowerShell Reviewed by Salaudeen Rajack on 3:18 PM Rating: 5

SharePoint Online: How to Check in a Document using PowerShell CSOM?

5:11 PM    , , ,
Check out-Check in feature in SharePoint avoids conflicts in typical collaboration environments, where multiple users may try to edit the same document at the same time. You must check in the document back in order to make the changes available to all other users, Even if the document is saved. How to Check-in a document in SharePoint online? To check in a checked out file, follow these steps in SharePoint online. Navigate to the document library where the checked out file is saved. Select the document(s) to Check in.   From the ribbon, click the Files tab, click on "Check In" from the "Open & Check Out" group. In the Check In dialog box, click No for "keep the file checked out after checking it in" option. Click OK. If you Checking in a document but retain it to checkout, other users get to see your latest changes while you may continue to work on the rest of the changes to your document. SharePoint online PowerShell to check in a docu
SharePoint Online: How to Check in a Document using PowerShell CSOM? SharePoint Online: How to Check in a Document using PowerShell CSOM? Reviewed by Salaudeen Rajack on 5:11 PM Rating: 5

SharePoint Online: How to Checkout a Document using Powershell CSOM?

3:16 PM    , , ,
Checking out a document in SharePoint ensures that you are the only one making edits to it. The purpose of checkout is to prevent conflicts in a collaboration environment where multiple people may try to edit the same document or list item at the same time. So, When a file is checked out to you, you are the only one allowed making changes to it. The file will remain locked until you release it. When you're finished making edits, check in the document so that other users can view the changes you made. The option of "Require checkout" can be turned ON or OFF from document library settings. How to Check out a document? Navigate to the document library in your SharePoint or SharePoint online site. Select the document which you would like to checkout.  On the ribbon, click on Files tab, Click on "Check Out" button. (or you can checkout from the item's context menu) Once the document is checked out, you'll get a tiny outward-pointing  green arrow, i
SharePoint Online: How to Checkout a Document using Powershell CSOM? SharePoint Online: How to Checkout a Document using Powershell CSOM? Reviewed by Salaudeen Rajack on 3:16 PM Rating: 5

SharePoint Online: Check if File Exists in Document Library using PowerShell CSOM

2:15 PM    , , ,
Requirement: Check if a file exists in SharePoint online document library using PowerShell CSOM. PowerShell to check if a file exists in SharePoint online document library: Lets check if file exists in SharePoint document library with 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" #Function to Check if file exists in given URL Function Check-FileExists($SiteURL, $FileRelativeURL, $Credentials) { #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Credentials Try { #Try to get the File from URL $File = $Ctx.web.GetFileByServerRelativeUrl($FileRelativeURL) $Ctx.Load($File) $Ctx.ExecuteQuery()
SharePoint Online: Check if File Exists in Document Library using PowerShell CSOM SharePoint Online: Check if File Exists in Document Library using PowerShell CSOM Reviewed by Salaudeen Rajack on 2:15 PM Rating: 5

SharePoint Online: Check If Field Exists in List using PowerShell

12:09 PM    , , , ,
Requirement: PowerShell to check if a field exists in list in SharePoint online. SharePoint Online - PowerShell to check if a Column exists in List #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" #Function to Check if a column exists in a List Function Check-ColumnExists($SiteURL, $ListName, $FieldName, $Credentials) { #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Credentials #Retrive all Fields from the list $List = $Ctx.Web.Lists.GetByTitle($ListName) $Fields = $List.Fields $Ctx.Load($List) $Ctx.Load($Fields) $Ctx.ExecuteQuery() #Check if the given field name $Field = $Fields | where{$_.Title -eq $FieldName}
SharePoint Online: Check If Field Exists in List using PowerShell SharePoint Online: Check If Field Exists in List using PowerShell Reviewed by Salaudeen Rajack on 12:09 PM Rating: 5

SharePoint Online: Check if List Exists using PowerShell

12:03 PM    , , , , ,
Requirement: Check if a particular list exists in a given SharePoint online site using PowerShell CSOM script. PowerShell Script to check if List Exists 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 Check if Site Collection Exists in Given URL Function Check-ListExists($SiteURL, $ListName, $Credentials) { #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Credentials Try { $List = $Ctx.Web.Lists.GetByTitle($ListName) $Ctx.Load($List) $Ctx.ExecuteQuery() Return $True } Catch [Exception] { Write-host $_.Exception.Message -f Red Re
SharePoint Online: Check if List Exists using PowerShell SharePoint Online: Check if List Exists using PowerShell Reviewed by Salaudeen Rajack on 12:03 PM Rating: 5

SharePoint Online: Check if Site Collection, Subsite Exists using PowerShell CSOM

11:40 AM    , , ,
Requirement: Check if site or site collection exists in SharePoint online using PowerShell CSOM. SharePoint Online PowerShell-CSOM to check if site or site collection exists in given URL: This PowerShell script checks if site collection exists in the given URL. #Load SharePoint online 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 Check if Site Collection Exists in Given URL Function Check-SiteExists($SiteURL, $Credentials) { #Setup context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Credentials $Web = $Ctx.Web $Ctx.Load($web) Try { $Ctx.ExecuteQuery() Return $True } Catch [Exception] { Write-host $_
SharePoint Online: Check if Site Collection, Subsite Exists using PowerShell CSOM SharePoint Online: Check if Site Collection, Subsite Exists using PowerShell CSOM Reviewed by Salaudeen Rajack on 11:40 AM Rating: 5

Update SharePoint List Items from CSV File using PowerShell

12:24 PM    , , , , , ,
Requirement: Update SharePoint List Items from CSV file. Bit background: We've a list with 1000's of rows of organization wide experts. Later we added a new field for "Department". Now the requirement is to update Department field for specific list of users. While the datasheet view can be used for bulk editing, filtering and editing 100's of rows would be time consuming. So the solution is: Have list of user names and their departments in CSV file format, give it to PowerShell! PowerShell Script to Read from CSV file and Update SharePoint List Items: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Read the CSV file $CSVData = Import-CSV -path "C:\UserData.csv" #Get the Web $web = Get-SPWeb -identity "http://portal.crescent.com" #Get the Target List $List = $web.Lists["ExpertProfiles"] #Iterate through each Row in the CSV foreach ($Row in $CSVData) { #Get the List Item matching "N
Update SharePoint List Items from CSV File using PowerShell Update SharePoint List Items from CSV File using PowerShell Reviewed by Salaudeen Rajack on 12:24 PM Rating: 5
Powered by Blogger.