kwizcom banner advertisement

Restart SharePoint Timer Service Remotely using PowerShell

8:42 PM    , , , ,
SharePoint Timer service must be restarted for certain configuration changes in SharePoint administration activities. To restart timer service in SharePoint, follow these steps: Login to your SharePoint Web Front End Server(s) Open Services console ( Start >> Run >> Services.msc) From the "Services" console, Find "SharePoint Timer Service". Right click and choose "Restart" from the Menu. Restart SharePoint Timer Service using PowerShell: Well, without logging into each and every SharePoint server and restarting timer service, we can utilize PowerShell to do it remotely! Use: Restart-Service sptimerv4 PowerShell Script to Restart SharePoint Timer Service Remotely: #Service to Restart $ServiceName = "SPTimerV4" #Array to Hold server Names. Update this Array accordingly $ServerNames = @("SPServer01", "SPServer02", "SPServer03") #Get All SharePoint Servers and restart their SharePoint
Restart SharePoint Timer Service Remotely using PowerShell Restart SharePoint Timer Service Remotely using PowerShell Reviewed by Salaudeen Rajack on 8:42 PM Rating: 5

Get SharePoint Site Collection, Web, List Objects from GUID

4:04 PM    , , ,
Requirement: On Nintex workflow databases, Ran a query to fetch workflow usage statistics, and the query gave GUIDs of SPSite, SPWeb and SPList objects! SELECT TOP 100 I.WorkflowName, I.WorkflowInstanceID, I.SiteID, I.WebID, I.ListID, I.ItemID, I.WorkflowInitiator, I.WorkflowID, I.State, COUNT(P.WorkflowProgressID) as WorkflowProgressRecords FROM WorkflowInstance I inner join WorkflowProgress P WITH (NOLOCK) ON I.InstanceID = P.InstanceID --WHERE i.State=2 GROUP BY I.WorkflowName, I.WorkflowInstanceID, I.SiteID, I.WebID, I.ListID, I.ItemID, I.WorkflowInitiator, I.WorkflowID, I.State ORDER BY COUNT(P.WorkflowProgressID) DESC Well, from SQL query we got GUIDs of SharePoint site collection, web and list objects, but how do we get the actual site collection/site/list locations? PowerShell comes to rescue. Here is the PowerShell script to get SharePoint site collection, web, list objects from GUID. [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Shar
Get SharePoint Site Collection, Web, List Objects from GUID Get SharePoint Site Collection, Web, List Objects from GUID Reviewed by Salaudeen Rajack on 4:04 PM Rating: 5

Open PDF Documents in New Window in SharePoint

6:39 PM    , , , ,
By default, PDF documents are opened in the same browser window in SharePoint. Here is the trick to open PDF files in new window: Option 1: Open PDF in new window with jQuery Use this jQuery to script to open SharePoint 2010 PDF documents in a new window: <script src="https://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script> <script> $(document).ready(function() { $("a[href$='.pdf']").removeAttr('onclick').attr("target","_blank"); }); </script> This script can be placed in Master Page, in Script editor/Content editor web parts or as part of SharePoint 2013/2010 delegate controls! Option 2: Configure Client Settings to Open PDF in Client Application instead of Browser If Office Web Apps isn't integrated with your SharePoint 2013, you can configure these options at client side: Go to Adobe Reader >> Edit >> Preferences Under Internet tab >> U
Open PDF Documents in New Window in SharePoint Open PDF Documents in New Window in SharePoint Reviewed by Salaudeen Rajack on 6:39 PM Rating: 5

Download Attachments from SharePoint List Programmatically

5:25 PM    , , ,
This code is a C# version of my earlier post: Download All Attachments from SharePoint List Items using PowerShell Download attachments from SharePoint list using C# Object model: //Variables String SiteURL; String ListName; String downloadLocation; //Get all inputs Console.WriteLine("Enter the Site URL:"); SiteURL = Console.ReadLine(); Console.WriteLine("Enter the List Name:"); ListName = Console.ReadLine(); Console.WriteLine("Enter the Download Location:"); downloadLocation = Console.ReadLine(); using (SPSite oSPsite = new SPSite(SiteURL)) { using (SPWeb oSPWeb = oSPsite.OpenWeb()) { oSPWeb.AllowUnsafeUpdates = true; //Get the List SPList list = oSPWeb.Lists[ListName];
Download Attachments from SharePoint List Programmatically Download Attachments from SharePoint List Programmatically Reviewed by Salaudeen Rajack on 5:25 PM Rating: 5

SharePoint 2010 Search Scope Drop Down Missing?

6:00 PM    , ,
SharePoint 2010 search drop downs such as "All Sites", "People" missing in site collections? Shows only "Search This site..." in search box? Well, That's the default setup in SharePoint 2010. Enable SharePoint 2010 add search scope drop down : How to enable search scope drop down in SharePoint 2010? simple, follow these steps: Make sure you have a Search Center site created already, before proceeding to these steps. Go to Site Actions >> Site Settings  Click on "Search Settings" link under Site Collection Administration group. Under "Site Collection Search Center" section, Choose "Enable Search Scopes" and enter the URL of your search center. On "Site Collection Search Dropdown Mode", choose "Show Search Dropdown" Click "Ok" to save your changes. Now the searh box should show you a drop down with "All Sites", "People" Scopes in SharePoint 2010 sites alon
SharePoint 2010 Search Scope Drop Down Missing? SharePoint 2010 Search Scope Drop Down Missing? Reviewed by Salaudeen Rajack on 6:00 PM Rating: 5

Export SharePoint List Items to XML using PowerShell

9:16 PM    , , ,
Sometime back, I wrote a PowerShell script to import from a XML file to SharePoint list, Import XML File Data into SharePoint List using PowerShell . Now the requirement is in reverse: Export SharePoint List data to XML file! PowerShell script to Export SharePoint List Items to XML: How to export SharePoint list to XML? Here in the PowerShell script! Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Set these three variables accordingly $WebURL = "http://projects.crescent.com/" $ListName = "External Projects" $XMLFilePath = "E:\data\ExternalProjects.xml" #Get the Web $web = Get-SPWeb $WebURL #Get the List $ProjectList = $web.Lists[$ListName] #Create a XML File $XMLFile = New-Object System.Xml.XmlDocument #Add XML Declaration [System.Xml.XmlDeclaration] $xmlDeclaration = $XMLFile.CreateXmlDeclaration("1.0", "UTF-16", $null); $XMLFile.AppendChild($xmlDeclaration) | Out-Null #Create Root Elemment &quo
Export SharePoint List Items to XML using PowerShell Export SharePoint List Items to XML using PowerShell Reviewed by Salaudeen Rajack on 9:16 PM Rating: 5

Change Master Page in SharePoint using PowerShell

4:01 PM    , , , , , ,
Requirement: Change Master page for SharePoint Site collections. After a branding redesign project, Got a requirement to change master pages on existing sites. branding on new sites going to be created. But for existing sites, We got to change master pages manually. SharePoint 2013 set master page using PowerShell: Lets change master page in SharePoint 2010 using PowerShell. Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue #Get the Web $web = Get-SPWeb "https://intranet.crescent.com/branding" #Prepare the Custom Master page URL $WebURL = $web.ServerRelativeUrl.TrimEnd("/") $MasterPageURL = $WebURL+"/_catalogs/masterpage/crescentv1.master" #Set Default and Custom Master pages $web.MasterUrl = $MasterPageURL $web.CustomMasterUrl = $MasterPageURL #Apply Changes $web.Update() Change master page sharepoint 2013 using PowerShell How about All sites in a site collection?Here is the PowerShell script in SharePoint 2013 to
Change Master Page in SharePoint using PowerShell Change Master Page in SharePoint using PowerShell Reviewed by Salaudeen Rajack on 4:01 PM Rating: 5

Activate-Deactivate Feature on All Sites, Site Collections in SharePoint using PowerShell

1:52 PM    , , , , ,
We use " Enable-SPFeature " and " Disable-SPFeature " PowerShell cmdlets in SharePoint 2013 / SharePoint 2016 sites to activate or deactivate features as in my another article: How to Activate-Deactivate Features in SharePoint . At times, we may have to activate feature for all site collections or deactivate feature on all sites. Here is my PowerShell scripts to do that. Enable a feature for all site collections in SharePoint: In my case, I had to enable "Open Documents in Client Applications" feature in every site collection under a web application to force opening documents in Office clients such as Microsoft Word instead of Office web apps due the licensing limitation. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #variables #$WebAppURL = "http://intranet.crescent.com" $FeatureName ="OpenInClient" #Get the Web Application $webApp = Get-SPWebApplication -Identity $WebAppURL #Get all site collectio
Activate-Deactivate Feature on All Sites, Site Collections in SharePoint using PowerShell Activate-Deactivate Feature on All Sites, Site Collections in SharePoint using PowerShell Reviewed by Salaudeen Rajack on 1:52 PM Rating: 5

Add-Remove Content Types to SharePoint List or Library using PowerShell

11:22 AM    , , , , , ,
SharePoint content types enables user to organize related data together. Everything is built around the content types in SharePoint to provide consistency and re-usability. Say for instance, All list templates such as Announcements, Tasks are built with content types "Announcement" and "Task" respectively! Typically a content type consists of template and metadata columns.  E.g. Lets consider "Sales Proposal document" content type which may be created at site collection with a template for sales proposal and columns to capture its related meta data, and can be associated with any number of document libraries. By default content types are scoped at site collection level. When you add a content type to a SharePoint list, its copied from site content type gallery to the list, which means when you customize content type at list level, it doesn't affect the parent content type which lives at site collection level. In OOPS terminology, you can consid
Add-Remove Content Types to SharePoint List or Library using PowerShell Add-Remove Content Types to SharePoint List or Library using PowerShell Reviewed by Salaudeen Rajack on 11:22 AM Rating: 5

SharePoint Web Part Usage Report - Find All Locations where a Particular web part is being Used

3:14 PM    , , , , , ,
During Migration, I had to get the URLs where a particular web part is being used. So, Used this PowerShell script to generate SharePoint web part usage report. This script made compatible with SharePoint 2007, So it can be used in SharePoint 2010 and in SharePoint 2013 as well. Just change the Web Application URL from "http://sharepoint.crescent.com" to yours. SharePoint Web Part Usage Report using PowerShell: [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") Function global:Get-SPWebApplication($WebAppURL) { return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL) } #Get-SPSite cmdlet for MOSS 2007 function global:Get-SPSite($url) { return new-Object Microsoft.SharePoint.SPSite($url) } Function global:Get-SPWeb($url) { $site= New-Object Microsoft.SharePoint.SPSite($url) if($site -ne $null) { $web=$site.OpenWeb(); } return $web } #Wri
SharePoint Web Part Usage Report - Find All Locations where a Particular web part is being Used SharePoint Web Part Usage Report - Find All Locations where a Particular web part is being Used Reviewed by Salaudeen Rajack on 3:14 PM Rating: 5

Create a SharePoint Subsite from Custom Site Template using PowerShell

12:48 PM    , , , , , ,
Requirement: We've a PMO site template created for managing projects in SharePoint. Had a new requirement to create some 20+ new PMO subsites based on the custom site template. To create a site based on site template, you can pick the custom tab and then select appropriate site template from the list. PowerShell script to create subsite from custom site template: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Custom function to create a site from site template Function Create-SubsiteFromTemplate($SiteTitle, $ParentSiteUrl, $TemplateTitle) { #Get the custom site template $ParentWeb = Get-SPWeb $ParentSiteUrl $SiteTemplates = $ParentWeb.GetAvailableWebTemplates($ParentWeb.Language) $CustomSiteTemplate = $SiteTemplates | Where-Object {$_.Title -eq $CustomSiteTemplateTitle} #URL for you new subsite $SiteUrl = $ParentSiteUrl + $SubsiteURL #create subsite without template $web = New-SPWeb -Name $SiteTitle -Url $Site
Create a SharePoint Subsite from Custom Site Template using PowerShell Create a SharePoint Subsite from Custom Site Template using PowerShell Reviewed by Salaudeen Rajack on 12:48 PM Rating: 5

Download All Attachments from SharePoint List Items using PowerShell

5:12 PM    , , , , , ,
Requirement: Download all attachments from a SharePoint list to local folder. Lets use PowerShell to download attachments from all SharePoint list items. PowerShell to Download Attachments from SharePoint List: [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") #For MOSS 2007 compatibility Function global:Get-SPWeb($url) { $site= New-Object Microsoft.SharePoint.SPSite($url) if($site -ne $null) { $web=$site.OpenWeb() } return $web } #Site URL and List Name variables $WebURL = "http://intranet.crescent.com/sites/purchase" $LibraryName = "Invoinces" #Local folder to which attachments to be downloaded $DownloadPath = "C:\Docs" #Get the web $Web = Get-SPWeb $WebURL #Get the Library $List = $Web.Lists[$LibraryName] #Loop through each List item foreach ($ListItem in $List.Items) { #Set path to save attachment $
Download All Attachments from SharePoint List Items using PowerShell Download All Attachments from SharePoint List Items using PowerShell Reviewed by Salaudeen Rajack on 5:12 PM Rating: 5

Find All Users Who Accessed SharePoint Sites in the Past One Year

2:15 PM    , , , , ,
Requirement: Get the E-mail ids of all users who accessed SharePoint sites during the past one year! Solution: Lets use Log Parser and PowerShell to fulfill this requirement. Here is how: Locate your SharePoint web application's log folders from all web front servers (usually: C:\WINDOWS\system32\LogFiles\W3SVCxxxxxxxxx\") using IIS. Make a note of them. Execute this log parser query by substituting LOG folders path, from any one of the Web Front end Use the data we received from log parser, pass it to PowerShell to query e-mails from active directory. Log parser query to get all users: @path=C:\Program Files\Log Parser 2.2\ LogParser -i:W3C "SELECT TO_LOWERCASE(cs-username) As UserName, count(*) as [Total Hits] INTO PortalUsersFeb.csv FROM E:\MOSS2007\LogFiles\W3SVC1297965057\*, \\MOSS07-WFE02\E$\MOSS2007\LogFiles\W3SVC1297965057\*, \\MOSS07-WFE03\E$\MOSS2007\LogFiles\W3SVC1297965057\* WHERE date > '2013-03-01' AND cs-username Is Not Null group by
Find All Users Who Accessed SharePoint Sites in the Past One Year Find All Users Who Accessed SharePoint Sites in the Past One Year Reviewed by Salaudeen Rajack on 2:15 PM Rating: 5

SharePoint 2013 deployment - Project Plan Template with Milestones

6:48 PM    , ,
Assuming Hardware, Public IP, SSL Certificates, Domain Names are ready - Here is my SharePoint 2013 deployment project plan template with milestones outlined: Deployment Tasks 0. Project Kick-off, Team-setup, Identifying key stake-holders and Responsibilities 1.Pre-Deployment Activities 1.1 Planning Logical Architecture, Topology, Service Accounts, Domain URLs, Naming Standards, etc. 1.2 Provision Service Accounts, DNS Entries & Delegations for SharePoint. 1.3 Prepare machines for SharePoint deployment (Adding Server Roles, Permissions, windows updates, etc.) 1.4 SQL Server Installation, Clustering / Mirroring / Always-ON. 2. SharePoint Installation 2.1.1 Install SharePoint binaries to Web and App Servers 2.1.2 Install Language Packs, Patch to recent build 2.2. Configure SharePoint Farm 2.2.1 Run SharePoint Configuration Wizard and Create SharePoint Farm 2.2.2
SharePoint 2013 deployment - Project Plan Template with Milestones SharePoint 2013 deployment - Project Plan Template with Milestones Reviewed by Salaudeen Rajack on 6:48 PM Rating: 5

SharePoint Products Configuration Wizard Failed to Connect to the Database Server.

6:29 PM    , , , ,
Problem: SharePoint sites crashed suddenly! Found event id 5586 "The target principal name is incorrect. Cannot generate SSPI context." logged in SharePoint servers. Tried running SharePoint 2013 Products configuration wizard. Received error message: "Failed to connect to the database server. Ensure the database server exists, is a Sql server, and that your have the appropriate permissions to access the server." Troubleshooting: Verified the Network connectivity, Port open in database server ( Netstat -a -n -o ) Made sure Firewall is disabled. TCP/IP, Named Pipe protocols are enabled in SQL Server. Verified the SQL Server service is up and running Verified all required permissions to connect with SQL Server. Made sure no service account is locked. Tried restarting the services and server. But when tried establishing a connection to SQL Server as in How to Check SQL Server Connectivity from SharePoint , it failed! The Final solution Worked for me:
SharePoint Products Configuration Wizard Failed to Connect to the Database Server. SharePoint Products Configuration Wizard Failed to Connect to the Database Server. Reviewed by Salaudeen Rajack on 6:29 PM Rating: 5

Enable Item-Level Permissions on Document Library in SharePoint using PowerShell

7:05 PM    , , , , ,
SharePoint Lists provide item level security options such as "Read items that were created by the user" or "Create items and edit items that were created by the user" under "Advanced Settings" page in SharePoint list settings. But you don't get these options to set Item level security in SharePoint document libraries! Say your requirement is to restrict users to view and edit other's documents and allow only their own documents in a document library! If you need these options, you can utilize PowerShell to enable Item level permissions on SharePoint document libraries as there is no UI available! These settings configures ReadSecurity and WriteSecurity properties of SPList object. Change Read Security with PowerShell: $web = Get-SPWeb "http://Your-SharePoint-Site" $list = $web.Lists["Your Document Library Name"] $list.ReadSecurity = 2 $list.Update() $web.Dispose() Where: Read all items: 1 Read items that were create
Enable Item-Level Permissions on Document Library in SharePoint using PowerShell Enable Item-Level Permissions on Document Library in SharePoint using PowerShell Reviewed by Salaudeen Rajack on 7:05 PM Rating: 5

Fix for Powershell Script cannot be loaded because running scripts is disabled on this system error

5:35 PM    ,
Problem: On trying to run a PowerShell script from PowerShell console, received this error message: "File C:\temp\GenerateRpt.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170." This is due to the PowerShell's policy to prevent untrusted scripts which can affect your Server environment. Solution: Open PowerShell Console by selecting "Run as Administrator" and set the execution Policy with the command: Set-ExecutionPolicy RemoteSigned Type "Y" when prompted to proceed  This in fact sets the registry key: HKLM\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell Policy parameter takes below values: Restricted - No scripting allowed Unrestricted - You can any scripting No signing required Remote signed – good for Test, Dev environments Only files from internet need to be signed This is the default setti
Fix for Powershell Script cannot be loaded because running scripts is disabled on this system error Fix for Powershell Script cannot be loaded because running scripts is disabled on this system error Reviewed by Salaudeen Rajack on 5:35 PM Rating: 5

Update "Created By", "Last Modified" Metadata Fields of a List Item using PowerShell

5:20 PM    , , , ,
Ever wanted to update SharePoint list or library item's metadata fields such as: "Created By" "Modified By" "Created" "Last Modified"? These column values must be updated while copying items from one list to another, programmatically. Today, Had an another requirement to update metadata fields in a document stored in SharePoint document library. Lets update these metadata fields such as "Created By" "Modified By" "Created" "Last Modified" using PowerShell. Update created by field using PowerShell in SharePoint: The below script changes created by in SharePoint list item . Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue #Set Configuration Parameters $WebURL = "http://portal.crescent.com/IQ/" $ListName = "Questionnaire" $ItemID = "147" $UserName = "Crescent\Hamid" #Get the Web, List, Item and User objects $Web= Get-SPWeb $WebUR
Update "Created By", "Last Modified" Metadata Fields of a List Item using PowerShell Update "Created By", "Last Modified" Metadata Fields of a List Item using PowerShell Reviewed by Salaudeen Rajack on 5:20 PM Rating: 5

Add New Field to Customized List Forms in SharePoint 2013

7:21 PM    , ,
Requirement: You have customized a SharePoint list form heavily. Now you got a new requirement to add a new field to the List, of course on List form as well. Unfortunately, when you add a new column to SharePoint list, custom forms have no effect - meaning new column will not appear on custom forms in SharePoint! So, This leads to create a new list form and do all customizations in the list form again from the scratch, isn't it? Well, Here is a trick to avoid rebuilding custom list forms when new fields are added to the list. Step 1: Refresh the data source Open your custom form (Say, New.aspx) in SharePoint designer Click on "Refresh data source" link in "Data Source Details" pane.  Not finding "Data Source Details" pane? Place the cursor under <SharePoint:DataFormWebPart> node, You'll find the "Data View Tools" Ribbon Group. Click on "Options" Tab and then click on "Data Source Details" button. This
Add New Field to Customized List Forms in SharePoint 2013 Add New Field to Customized List Forms in SharePoint 2013 Reviewed by Salaudeen Rajack on 7:21 PM Rating: 5
Powered by Blogger.