kwizcom banner advertisement

Add Lookup Field to SharePoint List using PowerShell

December 31, 2015    , ,
PowerShell script to add lookup field to SharePoint list: Scenario: You have a parent list called "Parent Projects" and child list "Project Milestones". The "Parent Project Name" field in child list is being looked up from the parent list's "Project Name" field. PowerShell to Add Lookup Field to SharePoint List: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #configuration parameters $WebURL="https://portal.crescent/Projects/" $ParentListName="Parent Projects" $ChildListName="Project Milestones" $ParentLookupColumnName="Project Name" $ChildLookupColumnName="Parent Project Name" #Get the Parent and Child Lists $Web = Get-SPWeb $WebURL $ParentList = $web.Lists[$ParentListName] $ChildList = $web.Lists[$ChildListName] #Check if Field exists already if(!$childList.Fields.ContainsField($ChildLookupColumnName)) { #sharepoint powershell - create lookup fi
Add Lookup Field to SharePoint List using PowerShell Add Lookup Field to SharePoint List using PowerShell Reviewed by Salaudeen Rajack on December 31, 2015 Rating: 5

Add Single line of text / Multiple lines of text Fields to SharePoint List using PowerShell

December 30, 2015    , , , , ,
How to Add Single Line of Text or Multiple Lines of Text Columns in SharePoint?  Browse to your list or library in SharePoint >> Click on the List or Library tab from ribbon. Click on "Create Column" button under "Manage Views" group.  In Create Column page, Type the Name for your column.  Select the type of the column as "Single line of text" or "Multiple lines of text" according to your requirement. In the Additional Column Settings section, provide values for fields such as description, Required Field, Unique, validation, etc. Click OK to save. How to programmatically Add a Single Line of Text field or Multiple Lines of text fields to SharePoint List using PowerShell: #configuration parameters $WebURL="https://portal.crescent.com/" $ListName="Service Requests" #Get site and List objects $web = Get-SPWeb $WebURL $List = $web.Lists.TryGetList($ListName) #Check if List Exists if($List) { #Setup Field Pr
Add Single line of text / Multiple lines of text Fields to SharePoint List using PowerShell Add Single line of text / Multiple lines of text Fields to SharePoint List using PowerShell Reviewed by Salaudeen Rajack on December 30, 2015 Rating: 5

Find Orphan User E-mails in List Items using PowerShell

December 30, 2015    , , , ,
Requirement: Our customized application for sending newsletters organizational wide, keeps its list of users to send e-mail in a SharePoint list called "Subscriptions". Users are configured in a people picker field of the list. Now, when someone leaves the organization, their account become orphan and their E-mails also goes invalid. So prior processing the E-mails column, we had to scan the people picker column in the list for orphaned user Emails. PowerShell script to scan for orphaned Users from their Emails: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue Import-Module ActiveDirectory $Web= Get-SPWeb "https://portal.crescent.com/News/" $List = $Web.Lists["Subscriptions"] $FieldName="Members" foreach($item in $List.Items) { if($Item[$FieldName] -ne $null) { #Get People picker field values collection $UserCollection = New-Object Microsoft.Sharepoint.SPFieldUserValueCollection($Web,$Item[$FieldName].
Find Orphan User E-mails in List Items using PowerShell Find Orphan User E-mails in List Items using PowerShell Reviewed by Salaudeen Rajack on December 30, 2015 Rating: 5

Add Column to View in SharePoint using PowerShell

December 30, 2015    , , , , , ,
How to add column to view in SharePoint? To add column in sharepoint view follow these steps: Browse to your list or library in SharePoint >> Click on the List or Library tab from ribbon. Select the appropriate view from the "Current View" drop-down. Default View gets listed in current view usually. Click on "Modify View" button under "Manage Views" group.  In Edit View page, Select the Columns you wish to appear in the particular View.  Click OK to save. This adds column to list view. PowerShell to Add a Field to View: How to add a column to SharePoint list view using PowerShell? Lets programmatically add custom column to view using PowerShell. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #configuration parameters $WebURL="https://portal.crescent.com/projects" $ListName="Project Milestones" $ViewName="All Items" $FieldInternalName="ProjectDescription" Function Add-F
Add Column to View in SharePoint using PowerShell Add Column to View in SharePoint using PowerShell Reviewed by Salaudeen Rajack on December 30, 2015 Rating: 5

Monitor SharePoint Services (Such as Timer Service) - Send Alert Email When They Goes Down!

December 29, 2015    , , ,
In continuation to my post Monitor SharePoint App Pools using PowerShell Script ,  If certain Services on SharePoint server goes down, that could cause outages or service interruptions to your SharePoint environment! Although monitoring solutions such as SCOM can monitor services, they can't start the service automatically - when stopped. So, lets address this issue with the help of PowerShell! Here is my nifty PowerShell script to start required services when stopped and send alert emails . This script not only scans services availability, but also: detects services status if its not in started state Automatically starts the service if its in stopped state Sends alert Email to SharePoint Admin team (or whoever configured!) PowerShell script to Monitor Services and Send Email notification: Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue #Configuration variables $EmailFrom = "ServiceMonitor@crescent.com" $EmailTo = "SPAdmi
Monitor SharePoint Services (Such as Timer Service) - Send Alert Email When They Goes Down! Monitor SharePoint Services (Such as Timer Service) - Send Alert Email When They Goes Down! Reviewed by Salaudeen Rajack on December 29, 2015 Rating: 5

PowerShell to Update Multi-valued Peole Picker Field with New Users

December 27, 2015    , , , ,
Requirement: Update existing People Picker field value using PowerShell in SharePoint. PowerShell script to Add an new user to existing People Picker field: We have a field called "Team Members" in Projects list and wanted to add new member(s) to it for a particular list item. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Configuration parameters $SiteURL = "http://portal.crescent.com/projects/" $ListName = "Projects" $FieldName= "ProjectTeamMembers" $UserToAdd="Crescent\Faris" $ItemID=431 #Get site and List objects $web = Get-SPWeb $SiteURL $List = $web.Lists.TryGetList($ListName) if($List -ne $null) { #Get the Item $Item = $List.GetItembyID($ItemID) #Get Existing field value $MultiUserCollection = [Microsoft.SharePoint.SPFieldUserValueCollection]$item[$FieldName] #Prepre the user to add $User = $Web.E
PowerShell to Update Multi-valued Peole Picker Field with New Users PowerShell to Update Multi-valued Peole Picker Field with New Users Reviewed by Salaudeen Rajack on December 27, 2015 Rating: 5

Break Permission Inheritance and Add-Remove Users to SharePoint List using PowerShell

December 26, 2015    , , , , , , ,
By default SharePoint Lists and Libraries are inheriting permissions from its parent site when created. There are times where you may want to implements unique permissions on a SharePoint list level. Say for e.g. if there are users who should access only a specific list in a SharePoint site but not any other object. So, to setup a unique permission on SharePoint site, list, library, folder, or item we should break the permission inheritance first. Just follow these steps: Navigate to your target SharePoint List or Library Click on List Settings >> and then Permissions for this list. From the ribbon, Click on "Stop Inhering Permissions" icon as in the below image. Breaking permission inheritance does not remove all existing permissions immediately! A copy of the parent's permissions is applied to the child object (such as List/item) before permissions are broken. Remove the Users or Groups who does need to have access to this list. Grant permissions to additi
Break Permission Inheritance and Add-Remove Users to SharePoint List using PowerShell Break Permission Inheritance and Add-Remove Users to SharePoint List using PowerShell Reviewed by Salaudeen Rajack on December 26, 2015 Rating: 5

Export SharePoint 2013 Search Crawl History to CSV using PowerShell

December 25, 2015    , , , , ,
Requirement: Extract crawl history of SharePoint 2013 search service application to a CSV file. PowerShell to Extract Last 10 Crawl Log History to CSV file: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Configuration Parameters $ContentSourceName = "Local SharePoint sites" $ResultsCount = 10 #Get Search Service application and Content Source $SearchServiceApplication = Get-SPEnterpriseSearchServiceApplication $ContentSource = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $searchServiceApplication | ? { $_.Name -eq $contentSourceName } #Get Crawl History $CrawlLog = new-object Microsoft.Office.Server.Search.Administration.CrawlLog($searchServiceApplication) $CrawlHistory = $CrawlLog.GetCrawlHistory($ResultsCount, $ContentSource.Id) #Export the Crawl History to CSV $CrawlHistory | Export-CSV "C:\CrawlHistory.csv" -NoTypeInformation
Export SharePoint 2013 Search Crawl History to CSV using PowerShell Export SharePoint 2013 Search Crawl History to CSV using PowerShell Reviewed by Salaudeen Rajack on December 25, 2015 Rating: 5

Update User Profile Properties in SharePoint using PowerShell

December 22, 2015    , , , ,
SharePoint User Profile properties are usually imported from Active Directory to provide information about SharePoint users. At times, we may have to update SharePoint user profiles manually. My scenario is to update user profile pictures from a SharePoint library. Here is my PowerShell script: PowerShell Script to update User Profile Property: #Configuration Variables $MySiteURL = "https://Mysite.Crescent.com" $UserLogin="Crescent\Salaudeen" #Get User Profile Objects $ServiceContext = Get-SPServiceContext -site $MySiteURL $UserProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext) #Check if user Exists if ($UserProfileManager.UserExists($UserLogin)) { #Get the User Profile $UserProfile = $UserProfileManager.GetUserProfile($UserLogin) #Update user profile picture Property $userProfile["PictureURL"].Value = "https://intranet.Crescent.com/UserProfileImages/Salaudeen.jpg" $us
Update User Profile Properties in SharePoint using PowerShell Update User Profile Properties in SharePoint using PowerShell Reviewed by Salaudeen Rajack on December 22, 2015 Rating: 5

Get-Set Person or Group (People Picker) Field Value using PowerShell in SharePoint

December 19, 2015    , , , , , ,
Peron or Group column in SharePoint captures user values. Here is my collection of PowerShell scripts to work with People picker field values: Read People Picker Field Value using PowerShell: PowerShell script to get value of Person or Group field. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Configuration Variables $SiteURL = "http://portal.crescent.com/sites/Sales" $ListName = "Tasks" $FieldName="Assigned To" #Get site and List objects $web = Get-SPWeb $SiteURL $list= $web.lists[$listName] #Iterate through each row in the list foreach ($Item in $list.Items) { #Get the People picker field value $AssignedTo = New-Object Microsoft.Sharepoint.SPFieldUserValue($Web,$Item[$FieldName]) #Get the Login Name of the user Write-host $AssignedTo.User.LoginName #Get the Email Write-host $AssignedTo.User.Email } Get Multi-valued People Picker Field Value (if Allow multiple selections
Get-Set Person or Group (People Picker) Field Value using PowerShell in SharePoint Get-Set Person or Group (People Picker) Field Value using PowerShell in SharePoint Reviewed by Salaudeen Rajack on December 19, 2015 Rating: 5

The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started. Please Contact your Administrator.

December 17, 2015    , , , ,
Error: The Managed Metadata Service or Connection is currently not  available. The Application Pool or Managed Metadata Web Service may not have been started.  Please Contact your Administrator.   Steps to troubleshoot: Check Managed Metadata Service is Running from SharePoint Central Administration site >> Manage services on server, Click on "Start" link next to "Managed metadata service" Start MMS Service application pool from IIS  Check IUSR is added in Anonymous Authentication in IIS: Open IIS, Click on your Server Name in left pane. Now open Authentication widget from the middle pane, Right Click on Anonymous Authentication and select Edit, Click on Specific User radio button and click on Set Button. Type IUSR in user name field and then click on OK. Check the permissions on Managed Metadata Service Application to your Web application's app pool account: Go to SharePoint Central Administration >> Application Management  >> Serv
The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started. Please Contact your Administrator. The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started. Please Contact your Administrator. Reviewed by Salaudeen Rajack on December 17, 2015 Rating: 5

Get/Set Managed Metadata Column Values using PowerShell

December 14, 2015    , , , , , ,
Here is my nifty collection of PowerShell scripts to read and update Managed Metadata field values in SharePoint: Read Managed Metadata column Value: PowerShell to get managed metadata field value. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $WebURL="https://portal.crescent.com/" $ListName="Deals" $FieldName="Region" $ItemID=1 #Get Objects $Web = Get-SPWeb $WebURL $List= $Web.Lists[$listName] $Item = $List.GetItembyID($ItemID) #Get MMS column Value [Microsoft.SharePoint.Taxonomy.TaxonomyFieldValue]$MMSFieldValue = $item[$FieldName] write-host $MMSFieldValue.Label Get Multiple Value MMS field values using PowerShell: When "Allow Multiple Values" Selected, here is how we can retrieve the value of it: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $WebURL="https://portal.crescent.com/" $ListName="Deals" $FieldName="Region" $ItemID=2 #
Get/Set Managed Metadata Column Values using PowerShell Get/Set Managed Metadata Column Values using PowerShell Reviewed by Salaudeen Rajack on December 14, 2015 Rating: 5

Managed Metadata Columns Usage Report in SharePoint using PowerShell

December 14, 2015    , , , ,
Requirement: Find the usage of all Managed Metadata columns in SharePoint environment. PowerShell script to find managed metadata column usage: Here is the PowerShell script to find all managed metadata columns in SharePoint site collection. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $SiteCollURL="https://portal.crescent.com" $ReportOutput="c:\MMS-Columns.csv" $WebsColl = (Get-SPSite $SiteCollURL).AllWebs #Array to hold Results $ResultColl = @() #Loop through each site, List and Fields Foreach($web in $WebsColl) { Write-host "Scanning Web:"$Web.URL Foreach($list in $web.Lists) { Foreach($Field in $list.Fields) { if($field.GetType().Name -eq "TaxonomyField") { $Result = New-Object PSObject $Result | Add-Member -type NoteProperty -name "List N
Managed Metadata Columns Usage Report in SharePoint using PowerShell Managed Metadata Columns Usage Report in SharePoint using PowerShell Reviewed by Salaudeen Rajack on December 14, 2015 Rating: 5

How to Rename a List or Library in SharePoint?

December 13, 2015    , , ,
How to rename a SharePoint list? Well, renaming SharePoint list is fairly a simple two step process. Lets rename a document library in SharePoint 2013. Browse to the document library >> Click on "Document Library Settings" under Library Settings group of the ribbon. Click on "List Name, Description and Navigation" link under General Settings. Provide a new name to your list under "Name" field. Click Save button to commit your changes. This renames list title in SharePoint. Rename a SharePoint list URL:  Renaming a list from SharePoint Web User Interface doesn't change the web address of the list. So, If you want to rename list URL, you can use SharePoint Designer, Explorer View or even PowerShell. Refer this post for further details: How to Rename SharePoint List URL using SharePoint Designer or PowerShell
How to Rename a List or Library in SharePoint? How to Rename a List or Library in SharePoint? Reviewed by Salaudeen Rajack on December 13, 2015 Rating: 5

How to Add a Column to SharePoint List using PowerShell?

December 12, 2015    , , , , ,
Requirement: Add columns to SharePoint list using PowerShell. PowerShell Script to Add Columns to SharePoint List: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue Function Add-FieldToList($SiteURL,$ListName, $FieldName, $FieldType, $IsRequired) { #Set the Error Action $ErrorActionPreference = "Stop" Try{ #Get the List $List = (Get-SPWeb $SiteURL).Lists.TryGetList($ListName) #Check if List with specific name exists if($List -ne $null) { if(!$List.Fields.ContainsField($FieldName)) { #Add columns to the List $List.Fields.Add($FieldName,$FieldType,$IsRequired) #Update the List $List.Update() #Update the default view to include the new column $View = $List.DefaultView # OR $List.Views["All Items"] $View.ViewFields.Add($FieldName)
How to Add a Column to SharePoint List using PowerShell? How to Add a Column to SharePoint List using PowerShell? Reviewed by Salaudeen Rajack on December 12, 2015 Rating: 5

PowerShell to Add-Remove Fields to Content Type in SharePoint

December 07, 2015    , , , , , ,
If you have a requirement to add a field to content type or remove a field from existing content type, use this PowerShell script: PowerShell script to Add a field to content type: #Get Web Object $web = Get-SPWeb "http://sharepoint.company.com" #Get Content Type and Field $ContentType=$web.ContentTypes["Content-Type-Name"] $FieldToAdd=$web.Fields["Field-Name"] #Add Field to Content type $FieldLink=New-Object Microsoft.SharePoint.SPFieldLink($FieldToAdd) $ContentType.FieldLinks.Add($FieldLink) $ContentType.Update() Lets add some error handling and make a reusable function to add site column to content type using PowerShell! PowerShell to Add Site Column to Content type in SharePoint  #Add SharePoint Snap-in Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue Function Add-FieldToContentType([Microsoft.SharePoint.SPWeb] $web, [string]$ContentTypeName, [string]$SiteColumnName) { #Get Content Type and Field (Site column) obj
PowerShell to Add-Remove Fields to Content Type in SharePoint PowerShell to Add-Remove Fields to Content Type in SharePoint Reviewed by Salaudeen Rajack on December 07, 2015 Rating: 5

Publish Content Type in SharePoint using PowerShell

December 06, 2015    , , , , , ,
Content types that we create in one SharePoint site collection should be published from Managed metadata content type hub in order to make the content type available in all other site collections which consume Managed Metadata Service application. How to publish from content type hub in SharePoint 2013? To publish a content type from the content type hub site in SharePoint, browse to your content type hub site collection, Navigate to: Site Settings >> Site Content Types  Select the content type that you would like to publish.  In content type settings page, click on "Manage publishing for this content type" link. From this page, you can publish a content type by selecting "Publish" and clicking on "OK". Also, If you make any changes to an existing published content type in content type hub site, you should republish the content type for the changes to take effect. Likewise, if you no longer want your content type to be available, you ca
Publish Content Type in SharePoint using PowerShell Publish Content Type in SharePoint using PowerShell Reviewed by Salaudeen Rajack on December 06, 2015 Rating: 5

Create Content Type Hub in SharePoint using PowerShell

December 04, 2015    , , , , ,
Content type hub in SharePoint is a central location to manage content types. Any web application subscribed to the content type hub can consume content types from this store. Creating content type hub in SharePoint using Central Administration web UI is explained in my another article: How to Create Content Type Hub in SharePoint 2013 , Now lets create content type hub in SharePoint 2013 using PowerShell. PowerShell script to create Content Type Hub in SharePoint: Creating content type hub in SharePoint involves three steps: Create an explicit Managed path for content type hub (optional) Create a top level site collection for content type hub Activate content type hub syndication feature Here is the Script: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Configuration Parameters $WebAppURL="http://intranet.crescent.com" $ManagedPath="CTypeHub" $HubOwner="Crescent\SPAdmin" $WebApp = Get-SPWebApplication $WebAppURL
Create Content Type Hub in SharePoint using PowerShell Create Content Type Hub in SharePoint using PowerShell Reviewed by Salaudeen Rajack on December 04, 2015 Rating: 5

Create Lookup Site Column from Subsite using PowerShell

December 02, 2015    , ,
Creating lookup field as site column was explained in my another post: Create a Cross-Site Lookup Site Column in SharePoint 2013 . Now got a requirement to create a lookup site column from the subsite's list! Unfortunately, there is no UI to create a site column from subsite list values. Lookup site columns can be created only from the lists of the same site. PowerShell comes to rescue! We can create a lookup site column referencing any site of the site collection using PowerShell! Here is the PowerShell script to create a lookup column from list on another site. PowerShell script to create lookup site column from subsite's (or different site) list: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Where the Source List for Lookup Exists $ParentWebURL="https://portal.crescent.com/sales/" $ParentListName="Regions" $ParentLookupColumnName="Region" #Where the Lookup Site column Going to get created $ChildWebURL="
Create Lookup Site Column from Subsite using PowerShell Create Lookup Site Column from Subsite using PowerShell Reviewed by Salaudeen Rajack on December 02, 2015 Rating: 5

How to Create a Cross-Site Lookup Site Column in SharePoint 2013?

December 01, 2015    , , ,
Lookup columns are used to get its value from a field in an another list in SharePoint sites. Lookup fields also provides a relationship between lists/libraries. Is it possible to create a lookup column from list on another site? sure, use site columns, so that you can utilize SharePoint 2013 lookup column from an different site! Site columns are available to its subsites, So create it in the Root site! SharePoint Site column Hierarchy: Create Cross-Site Lookup Site Column in SharePoint: Why to create Lookup as Site column? Because, If its created as a site column, it can be used at any subsite under the site collection while the lookup source list is at the parent site (or root site)! In short, create your lookup site column at parent site, so that it can be used on any underlying subsites of the site collection! Assuming, you have an existing list with all available lookup values in a "Single Line of Text" column, Here is how to create a cross site lookup site
How to Create a Cross-Site Lookup Site Column in SharePoint 2013? How to Create a Cross-Site Lookup Site Column in SharePoint 2013? Reviewed by Salaudeen Rajack on December 01, 2015 Rating: 5
Powered by Blogger.