kwizcom banner advertisement

Recover SharePoint 2007 / 2010 / 2013 Product Key using PowerShell

July 31, 2013    , , , ,
Ever wanted to recover your SharePoint 2007 or SharePoint 2010 Product key from an existing SharePoint Farm? Sure! Its encoded and stored in system registry and we can recover the license key with PowerShell. Here is the code: Here is the PowerShell Script to Recover SharePoint 2007 Product key: function Get-SP2007ProductKey { $map="BCDFGHJKMPQRTVWXY2346789" $value = (get-itemproperty "HKLM:\SOFTWARE\Microsoft\Office\12.0\Registration\{90120000-110D-0000-1000-0000000FF1CE}").digitalproductid[0x34..0x42] $ProductKey = "" for ($i = 24; $i -ge 0; $i--) { $r = 0 for ($j = 14; $j -ge 0; $j--) { $r = ($r * 256) -bxor $value[$j] $value[$j] = [math]::Floor([double]($r/24)) $r = $r % 24 } $ProductKey = $map[$r] + $ProductKey if (($i % 5) -eq 0 -and $i -ne 0) { $ProductKey = "-" + $ProductKey } } $ProductKey } #Call the function Get-SP2007P
Recover SharePoint 2007 / 2010 / 2013 Product Key using PowerShell Recover SharePoint 2007 / 2010 / 2013 Product Key using PowerShell Reviewed by Salaudeen Rajack on July 31, 2013 Rating: 5

Update All Items in a SharePoint List using PowerShell

July 30, 2013    , , ,
Use these PowerShell scripts to update all items in SharePoint lists: SharePoint PowerShell script to update all items in list: Requirement is to update all items in a SharePoint list using PowerShell script: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue ### Variables ### #Site URL and List names $SiteURL = "http://intranet.crescent.com/" $ListName = "Business Contacts" #Get site and List objects $web = Get-SPWeb $SiteURL $List = $web.Lists.TryGetList($ListName) if($List -ne $null) { #Get all List items $ListItems = $list.Items #Iterate through each item Foreach($item in $ListItems) { #To update a particular field, $item[$FieldName]= NewValue; #sharepoint powershell update all items in list $item.update() } } #dispose web object $web.Dispose() Filter and Update all documents in a SharePoint Libr
Update All Items in a SharePoint List using PowerShell Update All Items in a SharePoint List using PowerShell Reviewed by Salaudeen Rajack on July 30, 2013 Rating: 5

How to Rename SharePoint Web Application Name and URL?

July 25, 2013    , , , , , ,
We may want to change a web application name to make a consistency in naming conventions or in some other scenarios. But I don't find any SharePoint Central Administration options to rename a web application! So how to rename SharePoint 2013 web application Name? well, PowerShell can help! Rename SharePoint web application name using PowerShell:  PowerShell can be used to rename web application name in SharePoint 2013. Lets rename SharePoint web application using PowerShell Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Function to Rename SharePoint Web Application Function Rename-WebApp($OldName, $NewName) { #Get the Web Application by its Name $WebApp =Get-SPWebApplication | where {$_.Name -match $OldName} #sharepoint 2010 rename web application powershell $WebApp.Name= $NewName $WebApp.Update() Write-Host "Web Application Name Changed from: $($OldName) to $($NewName)" } #Call the function to Rename Web App Rename
How to Rename SharePoint Web Application Name and URL? How to Rename SharePoint Web Application Name and URL? Reviewed by Salaudeen Rajack on July 25, 2013 Rating: 5

SharePoint Workflows Inventory Report using PowerShell

July 16, 2013    , , , , , ,
In continuation with my another post: Workflows Inventory Report for SharePoint , which was done using C# object model code, This is a PowerShell version to find all workflows deployed in the SharePoint environment to generate the workflows Inventory report. Basically, this script iterates through all site collections-sites-List objects to fetch workflow data such as: Workflow Name, Running instances, etc. #For SharePoint 2007 Compatibility [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") Function global:Get-SPWebApplication($WebAppURL) { return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL) } #Function to Get the workflow inventory for the entire web application function Get-WorkflowInventory([string] $WebAppURL) { #Get the Web Application URL $WebApp = Get-SPWebApplication $WebAppURL #Iterate through each site collection foreach ($Site in $WebApp.Sites) {
SharePoint Workflows Inventory Report using PowerShell SharePoint Workflows Inventory Report using PowerShell Reviewed by Salaudeen Rajack on July 16, 2013 Rating: 5

Hide SharePoint List Columns based on User Permissions

July 15, 2013    , , ,
Requirement: We've a "Requests" link in our Help Desk site. The "Status" field in help desk requests list should be hidden when users create new entry in the list. Same time, Status field must be visible to people in "Help desk operators" group. So, the requirement is to hide SharePoint List Form field based on user permissions! Solution: Use SPServices to check whether the current user is member of a particular group. If not,  hide the field using jQuery (or you can make the field Read-only too: How to Make SharePoint List Column Read Only ). Here is the detailed steps: Place the below script in a text file, upload to any SharePoint library of the site. Edit the NewForm.aspx, Add a content editor web part just below form fields, point the script file in CEWP and make the content editor web part hidden. <!-- jQuery Reference. You can refer it from Layouts Folder/Doc Library too, after uploading the script. --> <script src="http
Hide SharePoint List Columns based on User Permissions Hide SharePoint List Columns based on User Permissions Reviewed by Salaudeen Rajack on July 15, 2013 Rating: 5

How to Make SharePoint List Column (Form Field) Read Only?

July 10, 2013    , , , , , , , ,
How to make a column read only in SharePoint 2010? Well, There are many ways. Here are some: Make column read only in SharePoint list programmatically use jQuery to make SharePoint field read only Using SharePoint designer to set field read only in list forms. Programmatically Set SharePoint list field to Read-Only using C# object model code or PowerShell script:   To make a SharePoint field read-only, We can set the " ReadOnlyField" property of SPField to "True" using either PowerShell script or C# code. Here is how:  Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Get the Web $web = Get-SPWeb "http://sharepoint.crescent.com/sites/pmo" #Get the List $List = $Web.Lists["Project Metrics"] #Get the Field $Field = $List.Fields["Project ID"] #Set the field to Read only $Field.ReadOnlyField = $true $Field.Update() See the detailed implementation at: Hide Columns in SharePoint List NewForm, EditForm a
How to Make SharePoint List Column (Form Field) Read Only? How to Make SharePoint List Column (Form Field) Read Only? Reviewed by Salaudeen Rajack on July 10, 2013 Rating: 5

Find and Delete Orphaned Users in SharePoint with PowerShell

July 08, 2013    , , , , , ,
Some times back, I posted an article on Orphaned Users in SharePoint. in short, SharePoint orphaned users are those who are deleted from Active Directory, but still have permissions to SharePoint sites!  Read more here: Find and Delete Orphaned Users in SharePoint PowerShell to Find and Delete Orphaned Users in SharePoint Now, with PowerShell, We can Find and Delete orphaned users in SharePoint. Here is the script: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Parameter $WebAppURL="https://sharepoint.crescent.com" #Function to Check if a User exists in AD Function Check-UserExistsInAD() { Param( [Parameter(Mandatory=$true)] [string]$UserLoginID ) #Search the User in AD $forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() foreach ($Domain in $forest.Domains) { $context = new-object System.DirectoryServices.ActiveDirectory.DirectoryContext("Domain", $Domain.Name) $domain = [
Find and Delete Orphaned Users in SharePoint with PowerShell  Find and Delete Orphaned Users in SharePoint with PowerShell Reviewed by Salaudeen Rajack on July 08, 2013 Rating: 5

Fix Custom SharePoint 2010 Logo Missing in Web Part Pages

July 08, 2013    , , , ,
SharePoint 2010 and SharePoint 2007 web part pages doesn't display the custom logo because they override PlaceHolderPageTitleInTitleArea place holder. Even though the new logo you applied reflects on all other places, Web part pages are still displaying SharePoint 2010's default logo. Well, Its a known issue. To fix this on web part pages, Navigate to: Site Actions >> Edit the page  Click on "Title Bar Properties" on the Page tab From the properties pane at right, add the URL to your site logo under Image Link Apply to bring Logo on SharePoint 2010 web part pages While the above steps are fairly simple and feasible for a single page, would be a pain in the *** for site with large amount of web part pages, isn't it? So, Lets do the change at master page level. Here is how: Open the master page in SharePoint designer Find the element: <SharePoint:SiteLogoImage name="onetidHeadbnnr0"   and replace the name attribute from "
Fix Custom SharePoint 2010 Logo Missing in Web Part Pages Fix Custom SharePoint 2010 Logo Missing in Web Part Pages Reviewed by Salaudeen Rajack on July 08, 2013 Rating: 5

Export SharePoint Users and Groups to Excel using PowerShell

July 08, 2013    , , , , , , ,
Requirement: Export SharePoint Users and Groups to Excel for analyzing SharePoint Groups and Users along with their Account Name, E-mails!We can export SharePoint User Group to excel using PowerShell. Here is how: PowerShell Script to Export Users & Groups: [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") #Using Get-SPSite in 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 } $URL="http://sharepoint.crescent.com/sites/csaportal/" $site = Get-SPSite $URL #Write the Header to "Tab Separated Text File" "Site Name`t URL `t Group Name `t User Account `t User Name `t E-Mail" | out-file "d:\UsersandGroupsRpt.txt"
Export SharePoint Users and Groups to Excel using PowerShell Export SharePoint Users and Groups to Excel using PowerShell Reviewed by Salaudeen Rajack on July 08, 2013 Rating: 5

Import from CSV to SharePoint List with People Picker Field Values

July 05, 2013    , , , ,
Requirement is: To add bulk of records from a CSV file to SharePoint list with People Picker field of "Allow multiple selections" set to "Yes". Unfortunately, SharePoint datasheet view doesn't allow us to copy-paste People picker values. So, I got to write the script! Here is my data to be imported to SharePoint list from CSV file: PowerShell Script to import CSV data to SharePoint list with people picker f ield [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") #Functions for Get-SPSite & Get-Web in 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 } $URL="https://sharepoint.crescent.com/sites/helpdesk/" #Read the CSV file - Map the Columns to N
Import from CSV to SharePoint List with People Picker Field Values Import from CSV to SharePoint List with People Picker Field Values Reviewed by Salaudeen Rajack on July 05, 2013 Rating: 5

Set SharePoint People Picker Default Value to Current User

July 05, 2013    , , , ,
Requirement: In a request tracking system, wanted to auto populate people picker value from currently logged in User. Solution:   How to set the People Picker field value to current user? Lets use jQuery and SPServices to fetch the logged in user name and fill the SharePoint list form's people picker field value. In short, Call SPServices function: SPGetCurrentUser() to retrieve the get the current user. Populate the people picker In SharePoint List Form using jQuery! Place this script in a text file, upload to any SharePoint library, Edit the NewForm.aspx page by appending ?toolpaneview=2 to the URL, Add a CEWP and locate the script in Content editor web part's property. <!-- jQuery Reference. You can refer it from Layouts Folder/Doc Library too, after uploading the script. --> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <!-- Download SPServices from: http://spservices.codeplex.com/ Or use this CDN --> <s
Set SharePoint People Picker Default Value to Current User Set SharePoint People Picker Default Value to Current User Reviewed by Salaudeen Rajack on July 05, 2013 Rating: 5

SharePoint Incoming Email does not Trigger Workflow

July 03, 2013    , , , ,
Today, created a Nintex workflow to send out E-mail notification to SharePoint groups. Start-up option for the workflow was: "Start when Items are created", but in SharePoint 2007 incoming email didn't trigger the workflow on new item creation. Root cause: Incoming E-mail attachments are uploaded to SharePoint libraries using "System Account" (If E-mail settings are set to: "Accept e-mail messages from any sender") which will not trigger workflows by design! What's the Fix for SharePoint workflow not starting on incoming email ? Well, the fix is simple! Just execute this STSADM command line: stsadm -o setproperty -pn declarativeworkflowautostartonemailenabled -pv true This fix applies to MOSS 2007 and SharePoint 2010 for incoming email to start workflow. Same fix applies to SharePoint designer workflows also! SharePoint incoming email doesn't trigger workflow by default, It works after the fix. By default, starting a workflow throu
SharePoint Incoming Email does not Trigger Workflow SharePoint Incoming Email does not Trigger Workflow Reviewed by Salaudeen Rajack on July 03, 2013 Rating: 5

Force Delete Corrupted SharePoint List using PowerShell

July 02, 2013    , , , ,
I got few corrupted lists when a custom code, which provisions lists got stuck in middle! I couldn't delete the corrupted list neither from SharePoint web interface nor using SharePoint Designer! When I tried to access the corrupted SharePoint list from browser, received this error message: "List does not exist. The page you selected contains a list that does not exist. It may have been deleted by another user." Alright, How to force delete corrupted SharePoint list? To delete corrupted list in SharePoint, we can either use STSADM command line tool or PowerShell. Delete corrupted list in SharePoint 2007 using STSADM: We can delete the corrupted list using stsadm forcedeletelist command. Here is how: Stsadm -o forcedeletelist -url <LIST URL> SharePoint delete list with PowerShell We can delete the corrupted list using PowerShell programmatically. Here is the script for SharePoint 2010 to delete corrupted list: #Get the Web $web = Get-SPWeb "<Sha
Force Delete Corrupted SharePoint List using PowerShell Force Delete Corrupted SharePoint List using PowerShell Reviewed by Salaudeen Rajack on July 02, 2013 Rating: 5

Delete Users from SharePoint Site Collection using PowerShell

July 02, 2013    , , , , , , , ,
Requirement: Delete user from site collection in SharePoint 2013  How to delete user from site collection? So you don't want a particular user to have access to SharePoint 2010 site anymore! Want to delete user from SharePoint 2010 site collection, isn't it? well, How to delete user from site collection? To delete user in SharePoint 2010, Navigate to the site collection as a Site collection Administrator Click on Site actions >> Site permissions Click on any SharePoint group. Now the URL will look some thing like: http://your-site-collection-url/_layouts/people.aspx?MembershipGroupID= 11 . Change the MemberShipGroupID parameter's value from 11 to 0. i.e. : http://your-site-collection-url/_layouts/people.aspx?MembershipGroupID= 0 and hit "Enter" key. This will lead you to see All People page. Select the user you want to delete, and click on Actions >> "Delete user from Site collection" That's it! By the way, to delete user
Delete Users from SharePoint Site Collection using PowerShell Delete Users from SharePoint Site Collection using PowerShell Reviewed by Salaudeen Rajack on July 02, 2013 Rating: 5

How to Run C# Code from PowerShell?

July 02, 2013    , , ,
Some time back, I wrote C# code for SharePoint Administration Governance purpose: Find Large Lists & Generate Report in SharePoint , which actually scans all lists in all sites and creates a report in CSV format. I feel PowerShell is more convenient than C# for couple of reasons: Because, PowerShell is quite powerful and more flexible administration and automation tool Although C# is good for typical Software development, for such small tasks C# project is overkill! Its faster to write, deploy and change it in PowerShell than creating a project in Visual Studio, compiling it, deploying it to the target, correcting the code, compiling it again, deploying it again! So, I wanted to leverage the existing C# code. While the code is relatively simpler to rewrite in PowerShell, Found another interesting way to run C# code in PowerShell. Here is an example: #Assemblies to Reference $Assembly = ( "Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=7
How to Run C# Code from PowerShell? How to Run C# Code from PowerShell? Reviewed by Salaudeen Rajack on July 02, 2013 Rating: 5

Membership Web part on SharePoint My Sites is not Updated

July 01, 2013    ,
Problem: Membership Web part on SharePoint My Sites is not Updated! still displays old data. Solution: Trigger a user profile Full import! That will update membership web part on SharePoint My sites! Here is how: Go to Central Administration >> Pick the relevant Shared Service Provider Click on "User profiles and properties" Click on "Start full import" link Watch and wait for the profile import to complete. Once the profile import is completed, your membership should be updated! If you are not getting "Start Full Import" link, which simply means, your profile import is either in progress or Stuck!
Membership Web part on SharePoint My Sites is not Updated Membership Web part on SharePoint My Sites is not Updated Reviewed by Salaudeen Rajack on July 01, 2013 Rating: 5

Content Editor Web Part Content Link Redirect - 404 Page Not Found Error

July 01, 2013    ,
Problem: A particular SharePoint site's Home page URL leads to 404 page not found error. While all other pages were working without any issues, On hitting the Home page URL, observed its redirecting to some other URL which doesn't exists! Root cause: Usually these kind of redirects are placed in CEWP using JavaScript. So, opened the page in SharePoint designer, tried locating the script, But could not find any such things. After an hour, found the problem. Actually user has placed a content editor web part and set the "content link" as an external web site's URL. That external web site URL was redirecting to some other URL on page load, which altered the actual SharePoint site URL. See the screen above: Solution: Simple! Delete the content editor web part with "Content link" pointing to a site, which redirects! just append ?contents=1 to the SharePoint site URL and close/delete the web part in Web part maintenance page.
Content Editor Web Part Content Link Redirect - 404 Page Not Found Error Content Editor Web Part Content Link Redirect - 404 Page Not Found Error Reviewed by Salaudeen Rajack on July 01, 2013 Rating: 5

Add a Link to Site Settings Page in SharePoint 2010

July 01, 2013    , , , ,
There was a requirement to get list owners info who created the lists, we developed a custom application page in SharePoint 2010: How to Create Custom Application Page in SharePoint 2010 to get List Owners But the link to the application page to be placed somewhere in the site for an easy access by site owners, isn't it? Where to link it? Site settings page would be the ideal place for such things! So lets add a link to site settings page in SharePoint 2010. SharePoint 2010 add link to site settings page 1. Create a new "Empty SharePoint Project" Farm Solution in Visual Studio 2010. Give it a Name. 2. Add an Empty Element to the Project. This will add "Elements.xml" file to the solution. 3.  Update the Elements.xml file with the below code: This adds group to site settings as well as add link in site settings page in that group. <!-- Add a Custom Group "Site Owner Reports" under Site Actions --> <CustomActionGroup Des
Add a Link to Site Settings Page in SharePoint 2010 Add a Link to Site Settings Page in SharePoint 2010 Reviewed by Salaudeen Rajack on July 01, 2013 Rating: 5
Powered by Blogger.