Saturday, December 13, 2014

Check for updates


Going through the Installed Updates list to check for a specific update that might or might not mess things up can be tedious using appwiz.cpl

Introduced in Powershell version 4 we have a new cmdlet for this purpose that come in handy.

Show list of all installed hotfixes
/> get-hotfix

Show if a specific update is installed:
/>get-hotfix -id "kb2843630"


References: – syntax

Friday, December 12, 2014

Users cant create subsites with publishing template

Funny thing happend the other day…
Site migrated from sharepoint 2010 to 2013. Certain groups can’t create subsites using Publishing template. They really want to…
Owners and members of constructor group can work fine.
Groups are using custom permission level.

- Creating subsite with publishing or publishing with approval workflow results in :
              - EventID 4965 – Web Content Management – Couldt initate … properties
              - Server Error in ‘/’ Application – Runtime error
              - ULS throws errors when trying to create.
- Works for members of owner or constructor group.
- Works when creating a non-localized default format publishing site.
- Works when creating Team Site



- Added Apply Themes and Border, Apply Style Sheets permission for the custom permission levels
- Added the relevant groups with read permissions for the /devicechannels list on each Site Collection.


Lessons learned:

- Devicechannels is a new feature of sp2013, permissions aren’t added automaticly if using custom groups, permissions levels and allowing for custom css.

References: -

Thursday, December 04, 2014

Cachehost is null

We're getting error Cachehost is null when trying to start Distributed Cache or removing the service with remove-spdistributedcacheserviceinstance

First of all verify these settings
- Windows Firewall have AppFabric Caching Service (TCP-Out) enabled on servers running DistributedCache
- Verify DistributedCache ports open between servers running Distributed Cache : 22233-22236 and Ping/Echo
- Verify following ports for AppFabric to talk sufficiently: 445, 139,135
- Can’t start Distributed Cache from the Central Admin
- Verify server and Active Directory talking ok.
- Verify DNS working

Verify status of Cachecluster. Is AppFabric and Sharepoint Server talking ok?
- Script : compareDCvsAppFabric-------
Add-PSSnapin microsoft.sharepoint.powershell

$instancename = "SPDistributedCacheService name=AppFabricCachingService"
$DC = get-spserviceinstance |where-object {($_.service.tostring()) -eq $instancename }
write-host "Sharepoint says..."
$DC |select typename, status,id,server |format-table

write-host "AppFabric says...."
Get-CacheHost |format-table

Result: Something is not ok. Sharepoint says fours servers and AppFabric says two. If same servers are reporting on both DC and AF then the problem is elsewehere.

Remove the serviceinstance from the missing servers and add them again.
Script below removes serviceinstance from the computer the script runs from!
---------script: forceremovedistcache.ps1 --------------
Add-PSSnapin microsoft.sharepoint.powershell

$instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName –and ($ -eq $env:computername}
write-host "Deleting instance $"

write-host "Adding distributed cache..."
write-host "Done"

Scenario 2: The other way around. AppFabric says other stuff than sharepoint.
Solution:  Remove the host from the cluster.
----script: remove host from cluster ----
Add-PSSnapin microsoft.sharepoint.powershell
$cachehost =  $env:computername

Unregister-CacheHost -hostname $cachehost -ProviderType SPDistributedCacheClusterProvider -connectionstring "<INSERTREGVALUE1>"

Where regvalue1 is found : HKLM\SOFTWARE\Microsoft\AppFabric\V1.0\Configuration\ConnectionString  (remove “;enlist=false” from the string)

And then try to add distributed cache again.

Lessons learned:
- In a locked down environment make sure all relevant Distributed Cache ports are open before adding the service to server.
- AppFabric and Distributed Cache is not the same thing! Appfabric is a windows service while Distributed Cache is a sharepoint service instance. They don’t always agree! Make sure they’re talking!


Sunday, November 23, 2014

Powershell and firewalls

Finally with Windows 8.1 and Server 2012 we have some new cmdlets that make managing firewall-rules much easier. Hopefully we can now put netsh to the everlasting rest.

Example script – blockapps.ps1

$rulename = "BlockSomething"
$appPath = "D:\temp\Myprogram.exe"
New-NetFirewallRule -displayname $rulename -Direction Outbound -Program $appPath -action Block


References: – cmd syntax

Tuesday, October 21, 2014

Disable loopback on a website

If you need to access a sharepoint webapplication from the actual sharepointserver and you can’t seem to be able to authenticate properly. Then it’s possible a loopback issue. This is a slightly more proper way to do it. Still not recommended on a productionenvironment, but when in a tight spot, reach for the hammer. HKEY_LM\System\CCS\Control\LSA\MSV1.0 New Multi-string value Named: BackConnectionHostNames =  and /> iisreset /noforce   References:

Tuesday, October 07, 2014

Powershell and xml

For future reference
script to read properties from a xml file and update specified values.
More of a proof of concept than any real world usage.
Good for any cocktailparty
----------------xmllooptest.ps1 ---------
$path = split-path -parent $MyInvocation.MyCommand.Definition
$inputfile = $path + "\myinputfile3.xml"
[xml]$xmlinput = (Get-Content $inputFile)

write-host $" is my value"
write-host "Server is:"$xmlinput.main.configuration.server
write-host "Result : "$xmlinput.main.configuration.result

Write-host "Looping sites..."
$sites = $
foreach ($site in $sites)
    write-host "-----"
    write-host $
    write-host $
    if ($ -match "my site 2")
    $ = "New property for site2"
    write-host $
----------------- myInputfile3.xml------------


      my site 1
      My even newer property

      my site 2
      New property for site2


Wednesday, June 18, 2014

Translate Windows error messages

Ive searched for this one for a while.
Translates localized Microsoft error message to english easier troubleshooting

Tuesday, May 27, 2014

Sharepoint Organisation information

Some guiding documents that are enlightning – Great post about the cost and putability of document management. – Governance and site-management – The Dublin Core Metadata Element Set. A standard for tagging documents. – 16 ways to get your users actually using sharepoint properly

A few nifty commandments

To check version on farm, when fighting schema-issues while migrating

/>get-spfarm |select name,buildversion


To check correlation id when an unexpected error has occurred

/> get-splogevent | ?{$_.Correlation -eq "CORRELATION ID"} | select Area, Category, Level, EventID, Message |Format-List

To convert users from windows-based to claims-based on a migrated webapplication.

/>convert-SPWebApplication -Identity "https://portal:80 -To Claims –RetainPermissions


Monday, May 19, 2014

Change default value on a choice column

To get a choice column with multiple selections to allow default values with multiple selections a calculated value is needed.

Note that this is mostly used in a Foundation environment where Terms are not allowed.

In the Default value field give formula: =";#Offer;#Deal;#" where Offer and Deal is valid column choices.




Friday, May 16, 2014

Crashed site

A customer intranet died the other morning. The is what happend.

First user notifies of error while trying to access.


I start to look into it.

- First issue. Low/none diskspace. Frees up so its workable. This does nothing for the site. Tries restart to no avail.

- Checks all IIS-sites and Application Pools. A lot of pools are stopped. Starts these up, but not difference.

- Notices that patches been applied the previous night. Server starts warning for diskspace soon after. Ok so maybe a patch requires psconfig. Runs this but are greeted with error: Failed to initiate the upgrade sequence…. Method not found ‘void Microsoft.Sharepoint.WorkflowServices.Iworkflowservice.upgrade….


searching for this error doesn’t give much. Tries to uninstall the workflow manager services for this seems to related. the workflow 2013 mananger has given some ache in the past and isn’t used anyways. This gives nothing.

Tries to access Central Administration and curiously this works to certain degree. Until tries to access Service Application then it throws iWorkflowServices errors again.


Looks deeper into the logs and finds issues with the patches being applied.


Ok, so maybe a patch was trying to be applied but got stuck on the diskissue and landed in some unfinished state?

Tries to download the latest updates to see if this is an issue. There is some, but it takes alot of time.

Checks the size of the culprits Kb2863829. Turns out this mother is 827MB, no wonder it takes time. AND the patch requires and psconfig run after completion!


Let the update run through and then runs psconfig again. Though this failes on the Task 8 in the first run (Failed to create sample data) another run let it finishes.

Now everything works again!

What to take with us from this experience?

Always have 10-20GB free space on the sharepointserver!


Friday, April 25, 2014

Shrink transaction log

When transaction log has grown to size that is too big to take backup, or space just isn’t available AND the database just isn’t that important that it should drag all others to lag-hell this might be done to solve the issue.

Note that there is a point to transaction files. If the database is so important that you can’t loose a minuts worth of transactions its really a necessary feature. But if that need isn’t there, the recovery mode could easily be changed to Simple to avoid the risk of losing space on an old server and therefore halting critical applications.

But here it is anyways.

  1. Change recovery mode to Simple on the overgrown database.
  2. Run query: dbccshrinkfile (mydatabase_Log,0)
  3. Change recovery mode to Full again to restore the logging.

If the transaction logs grows, its usually because their isn’t a real backupsolution running for the database. Use maintenance jobs or stored procedures if a real one isn’t available.

Thursday, April 24, 2014

Can’t create maintenance plans

For some security reason these are disabled on SQL Server 2008-2012 on some occasions. Might be a servicepack disables it. But maintenance plans are a nice tier 2 security precaution.

Get thrown this error when trying to create a maintenance plan


Ran following query on victimserver to solve it.


Wednesday, April 23, 2014

Manage stored wireless networks in W8

Microsoft, in all their wisdom, have removed the Manage my wireless network option that was available on the wireles interface in Windows 7 and earlier. So, how to we manage it now?

See stored wireless profiles

/> netsh wlan show profiles

Delete a profile

/> nets wlan delete profile name=mynetwork

To show saved information, including key

/> netsh wlan show profiles name=mynetwork key=clear


Or to use the gui-way

Charms>PC Settings>Networks>Connections>WiFi>Manage known networks

But only thing you can do from here is see the name and forget the network, so learn the cli way.


Wednesday, March 26, 2014

Where’s my search dude?

I made a customer installation of Sharepoint Foundation 2013 recently. Naturally I used the latest Slipstreamed Microsoft package with Service Pack 1.

Sure everything looks fine at first, but after first site collection is up and running I notice that the searchbox is missing. Sure, maybe a glitch, runs new full crawl, but nothing changes. Tries to create a new search center site, site creator throws a sorry my way.


Tries to create my own custom page and add the search webpart and get another fun message “Common Language Runtime detected an invalid progam”.


Ok, maybe language is an issue, installs localization pack for swedish and creates new site collection. Same error.

After searching for information on the issue someone makes me aware of the fineprint of Slipstreampackaged Foundation downloadpage


First time that field contained any relevant information!

Searching on forums shows a few MS-cases that all indicates that this is an issue which will be fixed in the April CU. So we have to wait I tell the customer, looking like a noob cause they don’t want to put in the extra time for a reinstallation sans SP1.

But today I found an update that solved the issue!  Curiously not by googling but in my rssfeeds…

Hero of the day is: KB2760625 March 2014 PU for SharePoint Foundation 2013

Note the package is claiming to aimed at Sharepoint Enterprise Server but it worked nicely on my Foundation.


Thursday, March 06, 2014

Shared Mailbox mail sent folder

In Exchange 2013 with Outlook 2010 client, mail sent dont land in the corresponding sent folder.

For example, If John has access to shared mailbox, mail he sends with info as sender will land in his personal sent folder. This makes John and John collegues confused.


  1. Make sure KB24591115 is installed, from 2010 so most likely.
  2. Add this registry value on Johns computer/session
  3. Key: HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Preferences
    Name: DelegateSentItemsStyle
    Type: DWORD
    Value: 1

    Or run FixIt on


Tuesday, March 04, 2014

The simplicity of Promoted Links

Ever gazed upon the startpage of a Sharepoint Team Site and wondered how you could make your own Get Started panel?


Its simpler than it looks.

  1. Create a List of type Promoted Links
  2. Create Items on the list, add images if you under Background Image Location
  3. Add list as a webpart
  4. Done



Wednesday, February 26, 2014

Hide page title

Before to the left, after to the right
  1. Create txt file named removepagetitle.txt
  2. Enter :
  3. <style>
    .ms-core-pageTitle{Display:none !Important;}
  4. Upload removepagetitle.txt to your site, for example Site Assets\CodeSnips\
  5. On page insert Content Editor, link your removepagetitle.txt
  6. Title disappears.
Obviously this also can be inserted to a central css and be rid of without pesky webparts, but nice if you want some options.

When using the oslo-masterpage code below seems to do the trick.
<style> #pageContentTitle { display: none !important; } </style>

Friday, February 21, 2014

Extract year from date in SPD

Create Sharepoint Workflow 2010

1. Create 2 variables, wholedate and year

2. Define functions

Set Variable:wholedate to currentitem:start time   (return field as ISOFormatted)

  then copy 4 characters from start of variable:wholedate(output to:variable:year)

  then log variable:year to the workflow history list




Thursday, February 20, 2014

Quick Steps in Lists

Often neglected, I find this hidden feature useful for making no-code solutions.
Its a bit messy though.
To create, go to SPD > List > Custom Action > Choose where the button should appear. Its not completly obvious in my opinion so I’ve listed the name and where they’ll appear below.
When creating the manually from SPD, we got more alternatives than when creating a Quick Step directly from the Webgui. For example we now can add a webaddress, which can lead anywhere, either a local place on the sharepoint or somewhere offsite.
ListItem – Shows on the submenu on the listitem.
Edit Form – Shows in the Edit Form.
Display Form – shows in the Display Form.
New Form – shows in the New Form
View – Shows in the List Ribbonmenu
From this custom actions we can also configure where the link should appear to some degree by modifying the Ribbon Location ID
For example, the Display Form button lands in the Manage container per default.
If I want to move this icon to right part of the form, I can change the .Manage. to .Actions.

References: - nice overview of where we can place our buttons.

Wednesday, February 19, 2014

Disable java warnings

Java keeps blocking my stuff.

Figure that Procurve switches doesn’t come with signed applets.

Nothing worked while trying to access a procurveswitch after latest Java-update. Wouldn’t even get the option of running anyways.

To get it running:

Java Control Panel > Advanced> Security > Mixed Code > Disable Verification


Now its only one warning about unsigned stuff, haven’t managed to kill this one yet.

I usually prefer to avoid java on my machines, but when it comes to Procurve-switches its unfortunately required.



What happend with Low?


Deploy MSI-package from GPO

To deploy msi package to from GPO.

1. Create GPO DeployPackage

a. User Configuration>Policies>Software Settings>Software Installation

b. Create new package, choose msi to deploy. Must be located on a shared folder that has read permissions for authenticated users (to include all domain computers).

c. Choose Published

d. Choose newly created package, Change Deployment>Deployment Type to Assigned and Check Deployment options>Install this application at logon

2. Deploy this GPO to an OU where the User object is located.

3. GPUpdate /force on both server and client.

4. If all works, the client will notice the policy and request a restart.

5. Package should deploy as soon as logged in.


Friday, February 14, 2014

Hide columnheaders on a webpart

To hide headers on a webpart
  1. Add a contenteditor webpart
  2. Edit HTML-source
  3. Paste
  4. <style>
    .ms-viewheadertr {
    DISPLAY: none
  5. Columns should disappear at once. Hide webpart from form.

References: cant hide when using publishing pages.

Thursday, February 13, 2014

Word with values from Document Library Columns


  1. Upload Wordtemplate to documentlibrary
  2. Create Site Content Type
  3. Advanced Settings > Enter url of wordtemplate in documentlibrary
  4. Associate site content type with your documentlibrary
  5. Edit Word Template in documentlibrary
  6. In Word, Insert > Quick Parts > Document Property >
  7. Choose your list columns, should be at the bottom.Place in wordtemplate at your leisure.
  8. Now, when creating new template from this Site Content Type the field will be automaticly populated with the columns values.

Using folders as metadata-masters

A handy feature to use when bulk-uploading documents to Sharepoint is the “Default Column Value”. This feature shines when using folders.

For example, say $user wants to upload 2000 images to an assetlibrary and wants to tag these with managed metadata values, 3 of them for a third of the lot and something else for the rest. Managed metavalues can’t be edited in datasheet view when using multiple values so this might take some time for $user.

In this case $user could create three folders in the assetlibrary and from Library Settings>Column Default Values > Folder  change the values as $user wants.


Now all documents copied to this folder, even from ExplorerView, will get these default values. Unless manually specifying something else.

The cool thing is that when the values have been set, $user can copy the images elsewhere in the documentlibrary and the metadata will still be attached. So folders can be used as a transitstation for settings metavalues. Or just be presented with a flat structure in the view.


Friday, February 07, 2014

Alerts not working for some users

Nuisance mayor.

A client had an issue with alerts not working for some users.


Sorry something went wrong. The following users do not have an e-maildress specified:

Turned out email issues overall for these users.

Tried did not succed.

  • Restarted Server
  • User Profile Sync new full
  • Removed failing users profile from User Profiles and did a new full sync.
  • Changed settings for email in AD, synced verified changes where coming through. Changed back, still same issue.


Tried running />get-spuser –web http://myserv | select userlogin,displayname,email 

Noted that email was missing for the difficult users. Now why is that?

Verifed that Replicable was activated on the User Profile Properties settings for the emailfield. All looked good.

Fixed it by running :

/>$myuser = get-spuser –web http://myserv |?{$_.displayname –like “*myuser*”}

/> set-spuser –identity $myuser –web http://myserv –SyncFromAD

To identify accounts with no email

/> get-spuser –web http://myserv | where {-Not $} |select userlogin,email

To output add |export-csv myusers.txt


External client weren’t so interrested in putting in more time to figure out exactly what was wrong in the first place. New users for example are adding their email field from the AD without any issues. The problem users were added to the site prior to defining the email attribut in the AD so that may have been an issue aswell. Im still fidning it odd that the email were looking like they should in the User profile Services but not when using powershell. might be that the user profile service is making a lookup in the AD when browsing the profiles, but can’t be sure .

Solution found. Cause unknown. ill revisit this later.

References: – email not available efter moving user Tells us email must be added prior to adding user to sp.

Wednesday, February 05, 2014

Schedule a powershell script

When certain task has run, its nice to be notified. since email function is deprecated in taskscheduler we have to pull out powershell.


1. Create the script


$psemailserver = ""
$receiver =
$from =
$subject = "Task has run"
$body = "Scheduled task $task has run. "
send-mailmessage -to $receiver -from $from -subject $subject -body $body
write-host "Mail sent for $task"
write-eventlog -logname Application -source "my script" -entrytype information -eventid 1 -message "$task has run"

2. Create the call using Task Scheduler “powershell –file “c:\myfile\sendmail.ps1” “helloworld”

What the script does is take an input variable and sending an email using defined smtpserver in the script. When mail is sent, it also logs en event in the application eventlog with source “my script”. The param is optional, but helpful if you want more reusability.

The source needs to created the first time manually, or use an already existing source.

Create source “my script” in application

/>New-eventlog –logname application –source ”my script”


Thursday, January 30, 2014

Local SMTP with Sharepoint 2013

Sharepoint isn’t very flexible when it comes to email server.

Enter the local smtpserver.

  1. Install SMTPServer
  2. Configure SMTP-Service using IIS6.0 Management Tools
    1. Access>Relay image
    2. Delivery>Outbound Security>basic authentication image
    3. Delivery>Outbound Connection> Specify TCP port
    4. Delivery>Advanced image
    5. All OK.
  3. Configure Centralt Administration>Web Application> Outgoing email = myserver.mydomain.local

It should work immediatly. No need to reset IIS or restart the smtpserver.

Sometimes youre mailing servers you cant verify settings on. Then Gmail can be used to verify the mailflow.

For google

  • Basic Authentication = , pwd: mypassword, use TSL
  • Use TCP port 587
  • Smarthost =

To check email flow on local server, drive:\inetpub\mailroot\queue folder can be monitored. When mail is sent from sharepoint ,it lands in this folder while contacting the smtpserver. When there’s a problem, the mail will be stuck here. In some situations it might be needed to empty this folder, then content in this folder can be deleted if the iisadmin service first is stopped.

/>stop-service iisadmin

/>start-service iisadmin

/>start-service smtpsvc


Sunday, January 26, 2014

Excel datedif formula

Useful excelformula that is hidden from the common gui, but present in all version of excel.

To compare a date to today

Outputs difference in days. Can also return in complete months, years and then some.


Number of days

MNumber of complete months

Number of complete years


Number of days excluding years


Number of days excluding months and years


Number of months excluding years

Note that on Swedish systems formulas look like this instead:


Comma is replaced by semicolon for some reason.


Friday, January 24, 2014

Windows phone on Windows 8.1

While trying to copy files to my Lumia 520, my windows didn’t show the phone in my computer.

To solve this

1. Install Window Phone App

Why? I don’t know, this is supposed to work out of the box. But it might be an issue since Lumia 520 is a pretty cheap issue.

Or the issue might be that Metro-phone app stole the attention.

This is how its supposed to look: image

Now we can copy files like an usual folder.

Now, how do we do this wirelessly?

Thursday, January 23, 2014

Thumbs in Searchresults in SP2010

Was working from instructions trying to get Thumbnails from an Assetlibrary to be displayed in an Searchresultspage, but couldnt get the thumbs to stick.

Finally I tried removing “contentypeforsearch.=’image’  frome the xsl-customizations and it started working right away. Somehow the images in my results wasn’t interpreted as images. Maybe the .jpg filetype needs to added manually or something.

In this case, its a Imagesearch result page so the results are always images.

It works, im happy. customer happy. Done.


<xsl:when test="contenttypeforsearch[. = 'Image'] and contentclass[. = 'STS_ListItem_851']">


<xsl:when test="contentclass[. = 'STS_ListItem_851']">

References: – the moneyshot – a bit old, still generally informational. – details regarding how the crawling properties works.

Wednesday, January 22, 2014

Remove borders from View Style Boxed


For a case im using a link-list on a startpage. Reasons include making it easier for endusers to manage their own used applications, without rummaging around with tables etc.

For this reason the boxed view style served me well.


The box-borders gave an ugly look. To remove these, add content Editor webpart and insert

<style> {
    BORDER:0 !important;

Effect should be immediate.


Tuesday, January 21, 2014

Re-arm trial Server 2008+

While doing labs, applying snapshots and whatnot the licensekey sometimes disappears or you just dont wanna waste an activation on a testmachine.

To re-arm a Server triallicense

Elevated Cmd-prompt

Check current licenselevel

/>slmgr.vbs –dli

Extend the evalution period with another 60 days

/>slmgr.vbs –rearm

Server can be rearmed up to 3 times giving you a total of 240 days.


Monday, January 20, 2014

Shared folders using ps

To create a shared folder using powershell

New-SmbShare –Name ShareName –Path C:\LocalFolder

To get permissions on existing

Get-SmbShareAccess –Name ShareName



Thursday, January 16, 2014

Filtrera listvyer med localized Sharepoint

För en lokaliserad version av Sharepoint 2010 så används även svenska på de logiska funktionerna. Det är väl ok, när man kommer till ro med att det går att använda åäö på funktioner “Date=Datum,Year=År,Month=Månad etc”. Det som är knepigare att få grep och är varför de bytt ut skiljetecknen!

För att få fram en första dagen i en månad baserat på ett datumfält så funkar i Engelsk version denna:

=DATE(YEAR([Due Date]), MONTH([Due Date]), 1)
Motsvarande funktion på Svensk version:
Notera att “,” är utbytt emot “;” på svensk version. 

Så för att filtrera en listvy baserad på vilken månad som är angivet i ett fält kan följande metod användas.

  1. Skapa kolumn Visning(datumtyp)

  2. Skapa kolumn MonthEnd(beräknad) : formel =DATUM(ÅR(visning);Månad(visning);1)  output=dateimage[6]

  3. Skapa kolumn MonthStart(beräknad) : formel=DATUM(ÅR(visning);månad(visning)+1;1)-1   output=date

  4. Skapa vy,

    1. filtrera med MonthStart är mindre än eller lika med [I dag]

    2. Filtrera med MonthEnd är större än eller lika med [I dag]