Month: October 2011

PowerShell–Rename the ‘&’ in File Names

So recently I was moving large amounts of .DOC files into SharePoint libraries and it was occasionally causing an error due to invalid characters in the file name.  This was mostly due to having abbreviations in the names that included ampersands, for example “M&A Report 2010.doc”.  Now, looking at this, it’s an easy fix to replace the ‘&’ character with an underscore with PowerShell, this example does it for all files in a directory: get-childitem *.* | foreach { rename-item $_ $_.Name.Replace("&", "_") } Which works fine for the files within that folder, what if you want to do it recursively and include the subfolders?  no problem for PowerShell thanks to the ‘-recurse” flag: get-childitem *.* -recurse | foreach { rename-item $_ $_.Name.Replace("&", "_") } And there you have it, an easy and simple way to prep a file share or set of directories to move into a SharePoint...

Read More

SharePoint 2010–Mobility Redirect Feature

SharePoint provides a clumsy support for mobile devices by providing for List Views designated for mobile devices and automatic page redirect if the site is accessed by a mobile device.  By rendering column data in a format suitable for mobile devices it works, but it’s not a great experience in my opinion. By default Windows SharePoint Services ships with a “Mobility Redirect” feature that creates a default.aspx page in the /m folder of each site. For supporting users who what to access a mobile friendly version of the site, You have two ways to turn on the feature: Using stsadm.exe command line tool Stsadm -o activatefeature -name MobilityRedirect -URL “http://<URL>” Using PowerShell Enable-SPFeature -Identity MobilityRedirect -Url http://<URL> Remember that this is a SPWeb feature so you can turn it Off or On on an individual site.  Personally I don’t like the branding on the mobile view, so remember that when branding or developing sites for mobile devices, you can easily switch to mobile view of the page by using User Agent Switcher add-in for...

Read More

Replicating User Profile Data in SharePoint 2010

Having recently upgraded and migrated one of our farms from the old datacenter running 2007 to the new datacenter running 2010 there were some slight issues with the User Profiles and getting them moved to the new location.  Within SP2010 there are generally only two ways to get user profile data onto the new farm from an existing farm in SharePoint 2010. The first is to consume the User Profile Service of the host farm, but this causes issues if you want to host a My Site host (that contain personal sites) on the consuming farm. The second way...

Read More

SharePoint 2010 – Migrating Search Admin to Different Servers in the Farm

Recently one of the farms I work with got some additional servers joined to the farm. Rather than provisioning another WFE, we were expanding some of the back-end capacity. The Search Admin was running on a WFE, and we wanted to move search off to some dedicated servers. Here is the PowerShell script for moving Search Admin: $SSA = Get-SPEnterpriseSearchServiceApplication "Current Search Service App" $SA = Get-SPEnterpriseSearchAdministrationComponent -SearchApplication $SSA $SA | Set-SPEnterpriseSearchAdministrationComponent -SearchServiceInstance NewServerName –Force After moving the Search Admin you’ll want to kick start the crawlers with the following: Suspend-SPEnterpriseSearchServiceApplication $SSA Resume-SPEnterpriseSearchServiceApplication $SSA And as easy as that you can move search admin off to a new...

Read More

SharePoint 2010–Blocked File Types

SharePoint has a nice little security feature for blocking certain files from being uploaded to SharePoint libraries because of security issues. Each Web application maintains a list of blocked file types that is based on file name extensions. For example, you can block files that have the .exe extension because those files can be run on the client computer and can contain malicious code. I was asked a question the other day about blocked file types in SharePoint 2010 and how to allow them into a SharePoint repository. Now I realize that this is a massive risk but the client had a reason for wanting to do this because they wanted to store installation packages in a SharePoint library. This is generally considered not best practices, but if you have a site that is trusted and only a few individuals have upload rights, you are effectively creating a network share for installation packages. However, I will stress that you should never allow any executable file in your SharePoint site. But…there is an exception to every rule and this is probably one of them. Using SharePoint 2010 Central Admin First navigate to Central admin and once there click on the security section Once in the security section you need to be in General Security | Define blocked file types Here you will find a list of file with file type...

Read More

SharePoint 2010 – Cleaning up deleted databases

A service application database was deleted in SQL Server Management Studio. After a while, I noticed errors in the event viewer on the WFE and ULS logs complaining that SharePoint was not able to login to the database that I deleted. Obviously, SharePoint still thought that the database existed so I needed to find a way to remove it. PowerShell to the rescue!  Using PowerShell, run the following command: Get-SPDatabase | where {$_.exists -eq $false} This will list all databases in SharePoint that no longer exist on the database server. If the list is accurate and you wish to remove the orphaned databases, run the following command: Get-SPDatabase | where {$_.exists -eq $false} | foreach {$_.delete()} All orphaned databases should now be removed and SharePoint should stop complaining about being unable to login to the non-existent...

Read More

SharePoint 2010–Viewing XML for Search Core Results Web Part using XLS

Want greater understanding of what the heck is really coming back from your search results?  Just what sort of XML is being received?  XSL Transformations to the rescue! Using this little XLS transformation:   <?xml version=”1.0″ encoding=”UTF-8″?> <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output method=”xml” version=”1.0″ encoding=”UTF-8″ indent=”yes”/> <xsl:template match=”/”> <xmp> <xsl:copy-of select=”*”/> </xmp> </xsl:template> </xsl:stylesheet> You can replace the Search Core Results XLS Just make sure that before you replace the current XSL you copy and paste it into notepad.  I don’t think users appreciate having their search results come back displaying XML format!  Very useful when creating search driven applications and you need a quick peak under the...

Read More

Garden Gnome Nirvana with a Sports Twist

I came across an interesting website the other day: http://www.homeyardandgarden.com I do believe they have one of the most awesome array of garden gnomes I have ever witnessed. As a Chargers, Lakers and Dodgers fan, I felt it was my duty to share some of these with you.       It’s...

Read More