cloud.net

Thursday, September 8, 2011

Adding XPS indexing to SharePoint

It's pretty simple to add XPS indexing/support to a SharePoint 2010 search, but even so some people struggle. So just to make things real easy for you, I created a PowerShell script.
What you need to do:
  1. Logon to the server that's running SharePoint Server Search 14
  2. Copy the PowerShell script from below (some of it runs under right navigation)
  3. Paste it in to a text file > save as whatever.ps1.
  4. Run the PowerShell script.


Import-Module servermanager
$xps = Get-WindowsFeature XPS-Viewer
If ($xps.Installed -eq $FALSE) { Add-WindowsFeature XPS-Viewer }
If ((Get-PsSnapin |?{$_.Name -eq "Microsoft.SharePoint.PowerShell"})-eq $null) { $PSSnapin = Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-Null }
Write-Host -ForegroundColor White "- Adding registry values ..." New-Item -path "HKLM:\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\Filters\.xps" New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\Filters\.xps" -Name "Extension" -value "xps" -PropertyType String -Force | Out-Null
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\Filters\.xps" -Name "FileTypeBucket" -value "1" -PropertyType dword -Force | Out-Null
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\Filters\.xps" -Name "MimeTypes" -value "application/xps" -PropertyType String -Force | Out-Null
New-Item -path "HKLM:\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\ContentIndexCommon\Filters\Extension\.xps"
New-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\ContentIndexCommon\Filters\Extension\.xps" -Name "(Default)" -value "{1E4CEC13-76BD-4ce2-8372-711CB6F10FD1}" -PropertyType MultiString -Force | Out-Null
Get-SPEnterpriseSearchServiceApplication | New-SPEnterpriseSearchCrawlExtension "xps"
Stop-Service "OSearch14"
Start-Service "OSearch14"

2 comments:

Eric Halsey said...

Thanks for sharing saved me time! You'll need to edit the script a little if you simply copy and paste.

Thanks again,
Eric

rayone said...

Hi Eric.

What needs editing?
I just tried it on a completely virgin install of SP2010 and it worked flawlessly.


PS C:\Users\Administrator> C:\Users\Administrator\Desktop\xps.ps1

Success Restart Needed Exit Code Feature Result
------- -------------- --------- --------------
True No Success {XPS Viewer}
- Adding registry values ...

PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Set
up\Filters\.xps
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Set
up\Filters
PSChildName : .xps
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
PSIsContainer : True
Property : {}
SubKeyCount : 0
ValueCount : 0
Name : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\Filters\.xps


PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Set
up\ContentIndexCommon\Filters\Extension\.xps
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Set
up\ContentIndexCommon\Filters\Extension
PSChildName : .xps
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
PSIsContainer : True
Property : {}
SubKeyCount : 0
ValueCount : 0
Name : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\ContentIndexCommon\Filters\Extens
ion\.xps


FileExtension : xps
Parent : {Microsoft.Office.Server.Search.Administration.Extension, Microsoft.Office.Server.Search.Administration
.Extension, Microsoft.Office.Server.Search.Administration.Extension, Microsoft.Office.Server.Search.Adm
inistration.Extension...}