Blog

Nov 15
Cloning a Search Topology

Cloning a search topology is needed if you want to change any of the six components in Search Service Application. These six components can be viewed using PowerShell:

$ssa = Get-SPEnterpriseSearchServiceApplication

Get-SPEnterpriseSearchStatus -SearchApplication $ssa -Text

 

This will output your component names, their status and host.

1 Component Status.PNG

You need to make sure these components are in active running state. If not, cloning will work, but replacing degraded components will be a mess, and probably take longer time to fix than deleting the Search Service Application and start over. That's why it's a good idea to clone your topology when it's OK, and keep it on the server for use when your Search Topology run into trouble.

In this example, we'll change the root directory from default system disk to another drive. Let's start by getting a reference to the Search Service Instance.

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)

{

    Add-PSSnapin "Microsoft.SharePoint.PowerShell"

}

 

$hostA = Get-SPEnterpriseSearchServiceInstance -Identity "SP2013DEV"

 

Now you need to check that the search service instance is started by typing

Get-SPEnterpriseSearchServiceInstance $hostA

 

The output should state status Online.

2 Search Instance Status.PNG

If we're not online, you need to start the Search Server Instance by typing

Start-SPEnterpriseSearchServiceInstance $hostA

 

Keep checking with previous script until you get an online status. When the instance is up and running (and all components are active) it's time to make a clone.

$ssa = Get-SPEnterpriseSearchServiceApplication

$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active

$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $active

 

Now you have your clone, and can start working with it. The clone isn't active, and there can only be one active instance of your Search Service Application.

Now we need to create a new index component, with partition 0. It will generate IndexComponent2 since you already have IndexComponent1 in your clone topology

3 New Index Component.PNG

Make sure that this is the case by simply typing $clone and hit enter. You'll see that your clone topology now have seven (not six) search components.

4 Clone Instance.PNG

You can verify your created index component by typing

Get-SPEnterpriseSearchComponent -SearchTopology $clone -Identity IndexComponent2

 

Now it's time to remove the old index component by typing

Get-SPEnterpriseSearchComponent -SearchTopology $clone

Remove-SPEnterpriseSearchComponent -SearchTopology $clone -Identity IndexComponent1

 

When you run the second statement, you'll get a Confirmation request; hit the yes button

6 Confirm Remove.PNG

Again, verify that your clone now only have six components, and that the old IndexComponent1 is not part of the clone.

Get-SPEnterpriseSearchComponent -SearchTopology $clone

 

We're going to replace the Query Processing Component also, since it fails if you try to activate a new topology without a new query component. Redo the steps above, but this time with new query processing component.

New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance $hostA

Get-SPEnterpriseSearchComponent -SearchTopology $clone

Remove-SPEnterpriseSearchComponent -SearchTopology $clone -Identity QueryProcessingComponent1

 

Now you need to stop your Search Service Application in order to assign the new topology (clone) to our Search Service Application. First, verify that it is still running by typing

$ssa.IsPaused() –ne 0

 

If the statement returns false the Search Service Application is running. True means that it is paused (I know, a double negation, but it's what we have available). If it isn't paused we need to pause it by typing

$ssa.PauseForIndexRepartitioning() 

 

This command takes a while to execute, so don't worry. Pick up some coffee while you wait. When you get back your prompt, after the statement returns True, set our clone as the new active topology by typing

Set-SPEnterpriseSearchTopology -Identity $clone

 

This also takes a while, so enjoy your script working for you. You can open another instance of Management Shell to monitor the outcome. Just make a reference to the Search Service Application and get status by typing

$ssa = Get-SPEnterpriseSearchServiceApplication

Get-SPEnterpriseSearchStatus -SearchApplication $ssa -Text

 

If it fails, you can always activate the old topology by typing

$inactive = Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchTopology |? {$_.State -eq "Inactive"}

 

Find your old topology Id by typing $inactive and copy paste the Id in the following statement

$reactivate = Get-SPEnterpriseSearchTopology -SearchApplication $ssa |? {$_.TopologyId -eq "e67eee2e-d0be-49b6-b389-ec819788113f"}

Set-SPEnterpriseSearchTopology -Identity $reactivate

 

However, if everything is OK, you can remove the inactive topologies with the following one line script

Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchTopology |? {$_.State -eq "Inactive"} |% { Remove-SPEnterpriseSearchTopology -Identity $_ -Confirm:$false};

 

When you have activated your new topology, make an index reset from Central Administration and start crawling your content sources again.

 

Oct 08
PowerShell Online

​Yes, it's possible, but not as extensive as you're familiar on a SharePoint Server. Still, it's useful and as simple as on a SharePoint Sevrer installation. Before you begin - download the SharePoint Online Management Shell​. (I use Windows 8, and didn't need the ​Windows Management Framework 3.0. But if your installation fails, try this installing the WMF 3.0 first)​.

When installed, fire upp the SharePoint Online Management Shell and connect to your SharePoint Online Site using the Connect-SPOService​ cmdlet.​

> ​Connect-SPOService -Url https://contoso-admin.sharepoint.com -credential admin@contoso.com

SPOnlinemanagementShell.png

Hit enter, and you'll get a Login window to add your password. It's possible to login without the password request window if you type your Connect-SPOService script differently (shown in example 2 of the above link to the cmdlet). However, I save my scripts all the time, and don't want my password to the online site to be un-encrypted. So I type the password every time in the windows password text input field:
SPOnlinePowerShell.png

Typing the correct password, and you're in. Type Get-SPOSite and see what you got. :)

Saving the script to a .ps1 file, other familiar problems arise. You may need to set execution policy to run the script, and you must run the SharePoint Online Management Shell as administrator, to be able to change execution policy. Right-clicking I saw my other tool available... the PowerShell ISE. So I tried that one instead. If you have the PS ISE installed, no need to download SharePoint Online Management Shell either. Just connect, after you set the execution policy :)

Get-SPOSite.PNG

That's it. Now browse through the available cmdlets at ​​Index of Windows PowerShell for SharePoint Online cmdlets​ and see what you can do.​

Happy Scripting!

Oct 04
Manage Image Renditions

​Image Renditions is a way to create different views to be loaded on a site, without loading the whole image. That's important, because you don't want to load the web page with unnecessary content. I've experienced an entire site go down because of a very large image was added to a page - and with a lot of calls, making the web site behave like a server under DDOS attack. So Image renditions is a way to minimize that risk.

However SharePoint isn't an image editing tool, nor is Image Renditions, but you will get better performance using it than not using it.

Image Renditions on SharePoint Server has the following prerequisites:

  • Publishing site collection (or publishing feature enabled)
  • A configured BLOB cache
  • An Asset Library (recommended)

On SharePoint Online, it's already preconfigured. What you need to do is to create Image Renditions, edit them (if needed) and start getting better performance.

Chose Site Settings and in the Look and Feel section find Image Renditions:
 
Click Add new item
 
Specify name, width and height and save

Your image rendition gets a unique ID. Previously added and deleted renditions doesn’t show in the list, and the ID doesn’t change
 
Edit a page of your choice, and add an image (in Asset Library preferably). When you have the image on your page (taken from the asset library) select the Pick Rendition control in the Ribbon (image tab).
 

Use image renditions in HTML

Note: If the image URL includes the RenditionID parameter and Width and Height parameters, the Width and Height parameters are ignored.

The following example shows how to use the RenditionID parameter:

HTML
<img src="/sites/pub/Assets/Lighthouse.jpg?RenditionID=2" />
The following example shows how to use the Width and Height parameters:

HTML
<img src="/sites/pub/Assets/Lighthouse.jpg?Width=400&Height=200" />

Specify the image rendition in the image field control.

A developer can specify the image rendition to use in the image field control. Use the RenditionId property to set the ID of the image rendition. For more information, see RenditionId.

Crop (set viewport of rendition to be other than center)

Navigate to the asset library where the image you want to crop off center and mark the file name row. In the design tab select Edit Renditions.
 
Select which rendition to change (on this image only, and only in this site collection). You get a gallery of all available renditions for that image, and chose which one to change on the “Click to change” link below the image.
 
Change the rendition, and click OK. Note that edited renditions are dependent on a SharePoint Timer job and changes will take effect only when the job is finished.
 
Click Save – and see the result.​


Sep 27
Google Analytics and SharePoint Online?

​The first thing you need to do on your public facing web site is to add web analytics to measure your web traffic. Otherwise you have no idea what happens, where your visitors com from and what they do. For this purpose, I use Google Analytics, but there are other web analytics tools working well with Sharepoint Online.

In order to get this working, you need to add an app to your Sharepoint Online public web site. Sign in, and click settings > add an app. In the left menu, click SharePoint Store where you find a lot of useful apps. Click the link Public-facing Websites in the left meny.

SharePoint-Store.PNG 

Find the Web Analytics Integration and add the app to your public facing web site.

store-webAnalyticsIntegration.PNG 

Before you add it, you should look closely at the permissions. Read the app permission, and ask yourself if it is reasonable that you give permissions to this app.

permissions.PNG 

Last, when you add the app, you get another question (in pure Microsoft style) if you trust the app. When you accept the trust, you'll get a confirmation and installation begins.

webAnalyticsIntegration.PNG 

 

app-thankyounote.PNG 

On the site content page, you'll se the installation progress (without a progress bar, unfortunately).

app-install.PNG 

When finished, you see the app with the same color as other apps, meaning it's downloaded, but disabled. Click the app, and enable it.

paste-tracking-code.PNG 

You have the option to chose where you want your tracking code. To make the page faster on slow connections, I usually paste the code just befor closing of the </body> tag, in this case called end body script. Paste your Google Analytics tracking code, save and return to your website.

google-analytics-tracking-code.PNG 

Confirm that the added code is present in the source of the web site.

source-code.PNG 

 It takes a couple of minutes, before Google starts to track, but you can see for yourself that the tracking really works if you (in Google Analytics) select Real Time > Overview

ga-real-time.PNG 

So the answer is, yes - it's fairly easy to implement web analytics on your SharePoint Online public facing web site.

Reference: Use the Web Analytics Integration app.

Sep 21
Manage DNS and rename site

​I was under the impression that one could link several domains to one SharePoint Online environment. This is not the case. You have to choose which domain you want to use at any given time. You can't have both.

I tried to have both http://WebArchitect.se and http://SharePointOnline.se pointing to the same public web site. It can't be done, since you need to rename your public site collection to your domain name. I don't think I can use Alternative Access Mapping (AAM) either. So far I havn't layed my eyes on it.

Rename the site

website-domain.pngSwitching between verified domains is easy. Just select the checkbox next to your public URL, and click on the "Website Domain" button. This opens a modal dialog titled "Rename Your Website" (I'd really like to meet the User Experience Team on this labeling clash). Still on the Rename Your Website modal dialog, select the URL you want your public domain to have. Save, and wait for your current site to be deleted (the name that is). Reload your site collection page, and you see your newly created DNS record.

rename-website.png

Sep 21
Getting Started with SharePointOnline (SPO)

The intention of this site is to explore the possibilities with Sharepoint Online. So far I'm trying different DNS editing where the CNAME didn't work as expected. Instead I had to use A and point directly to the IP-address.

Probably this is a feature of my DNS-provider rather than a bug in SharePoint Online. To enable CNAME on my DNS-provider, I need to use a subdomain, which isn't of my interest.

The process begins with a MX-pointer from the DNS-provider making sure my domain is owned by me. When confirmed in SharePoint Online, you add a A-pointer from the DNS-provider to my SharePoint Online IP-address, which on default doesn't answer on PING. But you get the IP-address anyway using PING from your Command Prompt. The picture shows part of the SharePoint Admin Center, which is included in your SharePoint Online account.