kwizcom banner advertisement

Set Content Editor Web Part (CEWP) Content with PowerShell

5:51 PM    , ,
Scenario: We've a Project site collection with 100's of sub sites created for each project from a custom site template. Home page of each site has a content Editor web part with some content in it, titled "Dashboard Links". Years later, business wanted to change the content in the "Dashboard Links" in each site! So, Here the requirement is to set the Content Editor web part's content in all sub sites. Lets use PowerShell to automate: Set Content Editor Web Part (CEWP) Content with PowerShell Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Get the Site collection $site=Get-SPSite "http://sharepoint.crescent.com/PMO/" #Loop throgh each subsite in the site collection foreach($web in $Site.AllWebs) { #Get the Default.aspx file $file= $web.GetFile($web.Url +"/SitePages/Home.aspx") if($file.Exists) { #Web Part Manager to get all web parts from the file $WebPartManager = $web.GetLimite
Set Content Editor Web Part (CEWP) Content with PowerShell Set Content Editor Web Part (CEWP) Content with PowerShell Reviewed by Salaudeen Rajack on 5:51 PM Rating: 5

Get Query String and Set List Form Field Value using jQuery

4:17 PM    , , , ,
Years back, I used JavaScript for the similar requirement in SharePoint 2007: Get the value from URL Query String and populate the value of SharePoint list form field: How to Get the Query String from URL and Set SharePoint List Form field value? Now in SharePoint 2010, lets use jQuery to get query string from URL and populate list form field's value and SharePoint designer Quick Step to pass the query string value to target URL. Scenario: We've a "Projects" list with list of projects, and "Project Metrics" list to capture project metrics.We need to add project metrics to the projects from a context (ECB) menu item from Projects list. Overall Idea: Lets add a Quick Step using SharePoint designer to pass query string.  On clicking the Quick Step Link, say "Add Project Metrics", It navigates to the NewForm URL of Project Metrics list with QueryString "ProjectID". Lets get the query string from URL and set the NewForm's "
Get Query String and Set List Form Field Value using jQuery Get Query String and Set List Form Field Value using jQuery Reviewed by Salaudeen Rajack on 4:17 PM Rating: 5

Building Charts in SharePoint with Google Charts API

4:47 PM    , ,
Looking for a quick way to build Charts & Graphs from SharePoint list data? Here is the quickest way to create charts on SharePoint with Google Chart API ! Go to: http://usermanagedsolutions.com/SharePoint-User-Toolkit/Pages/Pie-Bar-Chart-Connector.aspx Provide "Edit view " URL in the given Text box. E.g. I've a List "Q1Summary" in Finance site collection. Edit view URL is: http://sharepoint.crescent.com/sites/finance/Q1Summary/_layouts/ViewEdit.aspx?List=%7BB9E23283%2DC445%2D4918%2D9229%2DB918FC2D71E2%7D&View=%7BB5A76744%2D98ED%2D422B%2D807A%2DCCBF1BF1F070%7D Specify other optional parameters such as Chart Type (Pie Chart, Bar, Column), Width, Chart title to generate chart code. Place the generated Chart code in Content editor web part The code generated would look like: <div id="spChart"></div> <script src="//www.google.com/jsapi" type="text/javascript"></script> <script type="text/ja
Building Charts in SharePoint with Google Charts API Building Charts in SharePoint with Google Charts API Reviewed by Salaudeen Rajack on 4:47 PM Rating: 5

Export SharePoint 2007 Search Crawl History using PowerShell

7:41 PM    , , ,
Here is the PowerShell script to export Search crawl history in SharePoint 2007 using PowerShell: [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") function global:Get-CrawlHistory($url) { #Objects to get Crawl History $site = new-Object Microsoft.SharePoint.SPSite($url); $context = [Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($site); $history = new-Object Microsoft.Office.Server.Search.Administration.CrawlHistory($context); Write-OutPut $history.GetCrawlHistory() #Dispose site object $site.Dispose() } #Call the function to get Crawl History Get-CrawlHistory -url "http://sharepoint.crescent.com" | Export-CSV "d:\Reports\CrawlLog.csv" This gives data such as: CrawlType (2 - Increment, 1- FULL), ContentSourceID ( 4 - Local Cr
Export SharePoint 2007 Search Crawl History using PowerShell Export SharePoint 2007 Search Crawl History using PowerShell Reviewed by Salaudeen Rajack on 7:41 PM Rating: 5

Download All Files From a SharePoint Library Programmatically using PowerShell

6:35 PM    ,
Ever wanted to download all files from a SharePoint Library (Document Library, Picture Library, etc) to your local drive? While downloading a single file or document is fairly straight forward by Clicking "Download a Copy" from documents Tab of the Ribbon or From the ECB Menu of the document  >> Send To >> "Download a Copy", downloading Multiple files or a complete folder is not that easy when the files count is high. Sure, Explorer view can do it! Go to the Document Library and choose Explorer View from the Ribbon Now you can drag & Drop (or Copy & Paste) folders, Files from and to your local drive from SharePoint. You can also use map your SharePoint libraries to network drive.  But How about downloading all documents from all document libraries? Yes, PowerShell can do it well! PowerShell Script to download all files and folders from a SharePoint Library along with its Structure: Add-PSSnapin Microsoft.SharePoint.PowerShell -Er
Download All Files From a SharePoint Library Programmatically using PowerShell Download All Files From a SharePoint Library Programmatically using PowerShell Reviewed by Salaudeen Rajack on 6:35 PM Rating: 5

How to Run SQL Server Query from PowerShell Script?

6:30 PM    , , , ,
For a migration project, there was a requirement to read from SQL Server table data , process the migration and then insert / update the tables back from PowerShell. We got to run SQL Server query from PowerShell. Here is how to query SQL Server using PowerShell: PowerShell to Run SQL Server Q uery Function QuerySQLServer([string]$DBServer, [string]$DBName, [string]$Query) { <# .SYNOPSIS Queries SQL Server from PowerShell .DESCRIPTION This PowerShell function Queries SQL Server from PowerShell .EXAMPLE QuerySQLServer "G1VWFE01" "MigrationDB" "SELECT [SourceSiteUrl], [TargetSiteUrl], [SiteType] FROM [MigrationData]" This example Gets table entries from the database "MigrationDB" in server "G1VWFE01" .INPUTS DBServer - Name of the Database Sever where the target database is located DBName - Name of the Database from which the query to be executed Query - Query to Execute .OUTPUTS Rows from the
How to Run SQL Server Query from PowerShell Script? How to Run SQL Server Query from PowerShell Script? Reviewed by Salaudeen Rajack on 6:30 PM Rating: 5

How to Prevent SharePoint List or Columns from Deletion?

9:10 PM    , , , , , ,
Scenario: We've a configuration list being used by a custom SharePoint application and we don't want to let the users to delete the configuration list in SharePoint. So how to prevent delete in SharePoint list? The idea is: Set the "AllowDeletion" property of the SharePoint list or Library to false. These properties can be set programmatically using object mode code C# or PowerShell. PowerShell script to Disable Delete on SharePoint List or Library: #Get the Web $web = Get-SPWeb "http://sharepoint.crescent.com/sites/pmo" #Get the List $list = $web.Lists["Design Documents"] #Set the "AllowDeletion" property $List.AllowDeletion=$false $List.Update() "Delete this document library" or "Delete this list" link will go hidden under list settings! We can use the C# code as well to disable delete option on SharePoint list and libraries: using(SPSite site = new SPSite("http://sharepoint.crescent.com/sites/pmo
How to Prevent SharePoint List or Columns from Deletion? How to Prevent SharePoint List or Columns from Deletion? Reviewed by Salaudeen Rajack on 9:10 PM Rating: 5

SharePoint 2010 Rating Feature Configuration - How to Activate? Fix Ratings not Updating Issue

8:16 PM    , ,
Rating feature was introduced in SharePoint 2010, It helps to rate Lists, Documents, Pages on a SharePoint site. How To Enable SharePoint 2010 Rating Setting: To setup SharePoint 2010 rating configuration, follow these steps: Navigate to your SharePoint site and then Target list or document library where you want Ratings to be enabled. Go to the list settings, Click on "Rating Settings" under the "General Settings" section Enable "Allow items in this list to be rated" and click OK. This will add rating columns to SharePoint 2010 list/library. Now you will see two new columns: the Ratings (0-5) and the Number of Ratings under the Columns section of list settings. Go to the list items view, You can set the ratings inline or edit a list item/document and set the  rating for the item by simply mouse over the stars in the Rating(0-5) column and set the ratings as needed. (You need Edit permissions, BTW) The next time the service timer job res
SharePoint 2010 Rating Feature Configuration - How to Activate? Fix Ratings not Updating Issue SharePoint 2010 Rating Feature Configuration - How to Activate? Fix Ratings not Updating Issue Reviewed by Salaudeen Rajack on 8:16 PM Rating: 5

SharePoint WSP Solution Deployment Stuck at "Deploying"

7:24 PM    , , , ,
Issue: SharePoint WSP Solution got stuck at "Deploying" stage for hours while trying to deploy using STSADM command in SharePoint 2007! Same thing happened in SharePoint 2013 also: Workarounds:  Try these workarounds to fix the solution deployment stuck at "deploying" stage. Make sure all your WFE & DB Servers in the Farm has no Time zone different! Make them aligned! Try running: stsadm -o execadmsvcjobs as the first step! Cancel the deployment, Remove the WSP and Re-deploy:  stsadm -o enumdeployments - This will give the GUIDs of all solution in "Deploying" State. Cancel the deployment using stsadm -o canceldeployment <GUID> command. E.g.: stsadm -o canceldeployment -id "95823b2b-8c92-4d08-99d5-7cf14c7be602" Delete the stuck solution with stsdm -o deletesolution -name mysolution.wsp -override Redeploy the solution. Try deploying for a single web application rather all. Try Restarting Timer Job on all servers of the
SharePoint WSP Solution Deployment Stuck at "Deploying" SharePoint WSP Solution Deployment Stuck at "Deploying" Reviewed by Salaudeen Rajack on 7:24 PM Rating: 5

IE 10 Browser Compatibility issues with MOSS 2007 and SharePoint 2010

6:03 PM    , , ,
Found so many user interface issues with Internet Explorer 10 while using it in MOSS 2007 and SharePoint 2010 sites. For instance, KPI didn't load, Grouped items stuck with "Loading.." message, "Save" button didn't work on SharePoint list forms, etc. Additionally, Experienced many JavaScript errors when tying Datasheet view, Multiple File Upload, etc. Temporary Fix: Set the Browser Mode to IE 8! How? Press F12, which fires IE Developer Tools. Select "Browser Mode: IE8". You can also try setting User Agent string to IE 8 from tools menu of IE Development tools. Permanent Fix: Install the Hot fix! http://support.microsoft.com/kb/2600100/en-us We can also force Internet explorer 10 to work on IE9 compatibility mode by setting the META tag in SharePoint Master page: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
IE 10 Browser Compatibility issues with MOSS 2007 and SharePoint 2010 IE 10 Browser Compatibility issues with MOSS 2007 and SharePoint 2010 Reviewed by Salaudeen Rajack on 6:03 PM Rating: 5

Delete All Document Versions in SharePoint Document Library using PowerShell

2:44 PM    , , , , ,
Requirement : Delete all old document versions in SharePoint site collection to free-up some disk space occupied by document versions. Because, simply disabling versioning does not deletes old versions which are already created until the next update happens on the document! So, If you want to release the space occupied by previous versions, you'll have to remove them manually. To Delete all previous versions of a document in SharePoint, follow these steps: Navigate to your SharePoint Library, click the ellipse (...) and then click on Version History From the version history page, click on "Delete all versions" link, confirm if prompted! PowerShell to Delete all Document Versions in SharePoint: Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue #Configuration Parameters $WebURL = "http://portal.crescent.com.com/projects/" $ListName = "Documents" #Get the Web, List objects $Web= Get-SPWeb $WebURL $List= $web.Lists[$L
Delete All Document Versions in SharePoint Document Library using PowerShell Delete All Document Versions in SharePoint Document Library using PowerShell Reviewed by Salaudeen Rajack on 2:44 PM Rating: 5

How to Hide SharePoint 2010 Ribbon Tab - Group - Button - Menu?

9:07 PM    , , , ,
How to hide Ribbon Tab - Group - Button - Menu in SharePoint 2010? But why? because, the requirement is: Users to fill the form and not upload any existing documents to the document libraries in a particular site. So wanted to disable Upload Document button from SharePoint ribbon. Solution: Override the existing SharePoint 2010 Ribbon Tab/Group/Button/Menu by creating an empty CommandUIDefinition! Steps in Detail: 1. Create an empty SharePoint 2010 farm solution project in Visual Studio 2010. Give it a name. Say, Crescent.TeamSites.HideUploadButton. 2. Add a new "Empty Element" item to the project. This will create a Feature with Elements.xml file. 3. Update the Elements.xml file with below content. <?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <CustomAction Id="RemoveRibbonButton" Location="CommandUI.Ribbon"> <C
How to Hide SharePoint 2010 Ribbon Tab - Group - Button - Menu? How to Hide SharePoint 2010 Ribbon Tab - Group - Button - Menu? Reviewed by Salaudeen Rajack on 9:07 PM Rating: 5

Open with Explorer Error - Alternate Method

6:24 PM    , ,
When you try to use "Open with Explorer" on SharePoint document library, Received Error "Your client does not support opening this list with Windows Explorer". You tried all the workarounds on Open with Windows Explorer Error: "Your client does not support opening this list with windows explorer" , but no luck! Well, there is a alternate to Open with Explorer. Map to Network Drive! Just go to My Computer >> Right Click "Computer" node from left side Tree view >> Choose "Map Network Drive" and provide the SharePoint document library location. You may be prompted to provide credentials. Once done, will get a New Drive in My computer, where you can copy/paste files as you do in windows explorer.
Open with Explorer Error - Alternate Method Open with Explorer Error - Alternate Method Reviewed by Salaudeen Rajack on 6:24 PM Rating: 5

How to Remotely Execute SharePoint 2010 PowerShell Cmdlets?

4:49 PM    , , , ,
PowerShell allows us to run cmdlets remotely from client machines. We can run SharePoint 2010 cmdlets on the SharePoint Server, remotely connecting from client machines by following these two steps: Step 1: To execute SharePoint PowerShell remotely, you have to enable PowerShell Remoting on the Server first! By default PowerShell Remoting is disabled. Log-On to the server you want to access remotely, enable remote PowerShell for running SharePoint 2010 cmdlets Enable-PSRemoting This command enables remote PowerShell for SharePoint 2010 by enabling WinRM service and configures windows firewall to allow incoming sessions.  Its a one time activity to configure remote PowerShell in SharePoint 2010. Step 2: Now, We can either directly invoke PowerShell Cmdlets or establish a session and then execute PowerShell cmdlets. E.g. To get the total no. of site collections, I'm using the below code:  Option 1: Invoke PowerShell remotely to run SharePoint 2010 cmdlets:  To Invoke
How to Remotely Execute SharePoint 2010 PowerShell Cmdlets? How to Remotely Execute SharePoint 2010 PowerShell Cmdlets? Reviewed by Salaudeen Rajack on 4:49 PM Rating: 5

How to Hide a List or Library in SharePoint?

9:48 PM    , , , , , , ,
How to Hide a SharePoint list or library from browser?  But why? Because, My custom application uses some configurations which should be stored and retrieved from a SharePoint list, but it must not be visible to end-users to avoid any mess. So, we got to hide our configuration list from users. We don't want the configuration list to be available to users, but visible only for the custom application code to read/write in it.  So lets hide the configuration lists from "View All Site Content" page. Solution: To hide a SharePoint 2007 or SharePoint 2010 list or library, either we've to use SharePoint API (Set SPList. Hidden property of the SharePoint list programmatically with either C# Object Model code or PowerShell) or use SharePoint designer. Even SharePoint itself uses lots of hidden Lists & Libraries for its own operations (E.g. "Content and Structure Reports", "Master Page Gallery", "Form Templates", "User Informat
How to Hide a List or Library in SharePoint? How to Hide a List or Library in SharePoint? Reviewed by Salaudeen Rajack on 9:48 PM Rating: 5

Change "Save" or "OK" Button Text on SharePoint List Forms

4:57 PM    , , , , , ,
Wouldn't it be more meaningful to rename SharePoint List NewForm.aspx "Save" or "OK" button text to "Submit" in Request Tracking Lists? Yes! Sure, I'll possible to change "Save" button's text to something else which gives more meaningful in the context. Using jQuery to Rename "Save" button Text: Place the below jQuery script in a text file, Upload it to a document library, add a CEWP to the NewForm.aspx page, and specify the "Content Link" in Content Editor Web Part's Property Pane. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script> <script> $(document).ready(function() { $("input[value$='Save']").attr('value', "Submit"); }); </script> Result in action: SharePoint 2010 change save button text Using JavaScript to Set SharePoi
Change "Save" or "OK" Button Text on SharePoint List Forms Change "Save" or "OK" Button Text on SharePoint List Forms Reviewed by Salaudeen Rajack on 4:57 PM Rating: 5
Powered by Blogger.