Sorry, there was a problem and we can’t open this document

Tags

,

I was testing migration of a SP 2010 site which used OWA to a SP 2013 environment. All was going well until I tried to open a word document and I saw this dreaded error:
CantOpenOWA
So fire up the search engines wearing your trouble shooting hat. And you will get tons and tons of posts in similar line.
Finally, I saw this post:
Sorry, there was a problem and we can’t open this document
This has a lot of suggestions. But after spending hours and hours, one line caught my attention:
“Does the url work from the WAC server”
Now I am not sure what “the url” refers to. But I presumed that must be the url of the restored site collection. In my case I did not have a DNS entry and was using a temporary entry in my host file. I made sure I enter the same entry in the OWA server and do a ipconfig /flushdns.
And bingo! The above error was gone!

Patching language packs and patching to August 2015 CU

Tags

,

I was tasked with patching our DEVELOPMENT environment from SharePoint 2013 SP1 to August 2015 CU. I thought – huh – that is easy! Boy was I in for a big surprise?
When I downloaded the August 2015 CU and started installing, I got an error whose screen shot I don’t have. But the error indicated that the language packs are not updated. First update the language pack and then it will let you update to the CU.
We have language packs installed in the same environment. But what version of language pack do we have? In the Patch Status page if Central Admin, you will see some version numbers for the language packs. But what do these version numbers  mean? We have great blogs posts for determining SharePoint version numbers. But I could not come up with any clue what version numbers to the right of the language packs mean. So I had to take chances. I assumed that we do not have language packs upgraded to SP1. So let me download the SP1 language packs and try to install them. Worst case, it will say we have nothing to install.
So where can I download the SP1 version of language packs? You should get started from here:
http://www.microsoft.com/en-us/download/details.aspx?id=42082
Once in this page, select the language packs one by one and download locally. If you have 5 language packs already deployed, you have to download the SP1 version of these language packs 5 times.
Once you are done downloading, copy to SharePoint servers and install one by one and run SP Product Configuration Wizard in all non database SharePoint servers.
Once the language packs are installed, it is time to download the August 2015 CU. When you try to install the binaries, the installation will fail.
From here, you will realize that this is a known issue and it needs to be installed 3 times:
http://blogs.msdn.com/b/tehnoonr/archive/2015/08/28/sharepoint-2013-august-2015-cumulative-update-package-fails-to-install.aspx
After the usual drill of running the Product Configuration Wizard, you have upgraded to August 2015 CU.
The next natural question is: are there language pack upgrades for August 2015 CU. For this I downloaded August 2015 CU for another language. I binary compared this with the English CU. I did not find any difference in them. Seeing this, I was pretty positive that there is no separate language pack for August 2015 CU.
The patch status page in our farm looks like the following now:
LangPack

How to checkin all checked out files via powershell? – With a twist

Tags

,

One day, I got a request from a colleague to bulk check in files he has checked out. He also pointed me to this great post:

http://sharepoint.stackexchange.com/questions/103610/how-to-checkin-all-checked-out-files-via-powershell

Thanks to Aanchal for this helpful post above.

However, as I often write, I work in a hurry in-between interruptions. Between phone calls and bosses stopping by. My colleague had the files scattered all over many folders and subfolders. Please note the following line:

$getFolder = $spWeb.GetFolder(“Shared Documents”)

If I run the above, I will barely touch the surface. Because all the files are distributed in unpredictable folders. On top of that, these were first time checkins. So
$_.CheckOutStatus -ne “None” does not quite catch these files. I however found that if you get the list and look for CheckedOutFiles, these files are captured. And then I used TakeOverCheckOut() for checking these files to me.
Here is the script, that worked for me:

Add-PSSnapin Microsoft.SharePoint.PowerShell

function CheckInDocument([string]$url, [string]$libName)
{

$spWeb = Get-SPWeb $url
$getLib = $spWeb.Lists.TryGetList($libName)

$getLib.CheckedOutFiles | ?{ $_.CheckedOutBy.UserLogin.ToLower() -match “Admin’s Network Id”.ToLower()} | %{

$myCheckedOutFile = $_

$myExactFolderName = $myCheckedOutFile.DirName.SubString(13) //This is //to get the exact folder path without the /sites/sitename, this number may //be different for you

$getFolder = $spWeb.GetFolder($myExactFolderName)

$getFolder.Files | Where { $_.CheckOutStatus -ne “None” } | ForEach {
Write-Host “$($_.Name) is Checked out To: $($_.CheckedOutBy)”
$_.CheckIn(“Checked In By Administrator”)
Write-Host “$($_.Name) Checked In” -ForeGroundColor Green
}
}

$spWeb.Dispose()
}

function CheckOuttoAdmin([string]$url, [string]$libName)
{
$spWeb = Get-SPWeb $url
$getLib = $spWeb.Lists.TryGetList($libName)

$getLib.CheckedOutFiles | ?{ $_.CheckedOutBy.UserLogin.ToLower() -match “mycolleague’sNetworkid”.ToLower()} | %{
Write-Host “Taking over Checkout $($_.LeafName)”
$myFile = $_
$myFile.TakeOverCheckOut()
}

$spWeb.Dispose()

}

CheckOuttoAdmin “Your Site Collection URL” “Shared Documents”

CheckInDocument “Your Site Collection URL” “Shared Documents”

SharePoint file locked/ Checked out when it is not

Tags

,

Last afternoon, my boss came over and told a very important user is reporting he cannot check out a file from SharePoint as it is locked by another user.

So I noted the file’s location and told him I will start looking. And I banged my head and scolded me for not saving note from the last time when I resolved this. This is the deadly error when the file is not really checked out, but it is locked. Oops. What to do?

After googling the Bing a lot, these are the useful sites that came up:

http://sharepoint-community.net/profiles/blogs/sharepoint-2013-multi-authoring-this-file-is-locked-for-editing

http://www.techtimepiece.com/2012/04/sharepoint-error-file-is-locked-for.html

http://mysharepointt.blogspot.com/2012/05/file-name-is-locked-for-editing-by.html

http://livinghitech.tumblr.com/post/54437075583/sharepoint-file-locked-for-editing

http://www.codeproject.com/Articles/251161/Resolve-SharePoint-Document-Locked-for-Editing-Iss

http://blog.ftechsoftware.com/blog/post/2011/09/06/Resolve-SharePoint-Document-Locked-for-Editing-Issue.aspx

But in our case the problem was we did not have access to the user. He was under the weather and gone. So I had to do it without the user.

This wait for 10 minute did not work for us at all.
https://support.microsoft.com/en-us/kb/899709


I am an admin and I have access to servers and PowerShell. This Back in the Hack post is the key to resolving this problem. Thanks to gavinmckay:
https://gavinmckay.wordpress.com/2015/04/10/howto-remove-the-lock-on-a-sharepoint-file/

The thing is I was in a hurry. Also this was in production and I did not have time to test and run this entire script. So I had to get this done via few commandlets.
Note that in this post there is a line which holds the key of the resolution. The line is
$impFile.ReleaseLock($impFile.LockId)

When I tried the above line, it bombed. That is because this was being tried with the admin context. It’s very important that you open the site as the context of the user to whom the file seems to be locked. Check out this line:

$impSite= New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken)

Here are the commandlets that were enough for me to do the release of the lock:

— Get the user

$myWeb = Get-SPWeb http://yoursiteurl (no pages/default.aspx)

$myFile = $myWeb.GetFile(“Shared Documents/****/****/your file name.xlsx”)

$myUserID = $myFile.LockedByUser.ID

$myUser = $myWeb.AllUsers.GetByID($myUserID)

— The following is the all-important piece, open the site as the user who locked the file and then release the lock

$impSite= New-Object Microsoft.SharePoint.SPSite($myWeb.Url, $myUser.UserToken);

$impWeb = $impSite.OpenWeb()

$fileURL = “Shared Documents/****/****/your file name.xlsx”

$impFile = $impweb.GetFile($fileURL)

$impFile.ReleaseLock($myFile.LockId)

Unable to open Office documents from SharePoint 2013

Tags

,

Some of us know about this:
Cannot open or create word documents in SharePoint 2013 with Office 2010 and Project 2013
In general when we get an error like below in the browser link:
ms-word:ofv|u|
then we tend to think that Office 2010 is mixed up with some Office 2013 components. So far, I never saw exceptions to this above rule. About a week back, I got a call from one user. And I confidently told him I know what is going on. And believe it or not, I could not find any trace of 2010 being mixed with 2013. And I gulped.
However, when I compared the version of Office 2013 365 Pro Plus between his machine and mine, I found his version does not match mine. So I requested our help-desk to repair his Office 2013 version and make it the same as mine. This resolved the problem.
Here is my laptop’s office version:
OfficeProblem

How to setup a development environment for office 365/ SharePoint online

Tags

,

I am a SharePoint Admin who dreams about migrating back to the development world. I attended this SharePoint/ Office 365 conference where I heard about the fact that I can setup an office 365 development environment practically free (about $8 a month) from the office dev environment. I am very bad at building virtual machines or laptops at home and always struggle with available time. So this is music to my ear. I thought I will give it a try on a Sunday afternoon after I was done with my exercise and other chores.
So where to begin? Let us begin at the office 365 developer site. The site is @
http://dev.office.com/
BTW, if you google the bing for Office 365 Developer Site, you will not find it. Easily at least. A very tempting link for Getting Started is right there. But let us not go there. Rather, on the left navigation, scroll down to DEV Program. Let us get started here.
You will see a Free Dev Program Sign Up link. I like free stuff. Let us sign up there and get our Office 365 subscription going.
Capture1
So now, we have our new shiny office 365 developer subscription. After signing up, you will get an email. A screen shot suggests that this is indeed for one year:
Capture2
My site is @ https://portal.office.com/Home
Guess what? I do not see SharePoint in my products in this screen:
Capture3
But I registered for learning development on SharePoint online. Undeterred, I click on the admin tile. On the left nav, under the Admin section, I see a link for SharePoint. On clicking that, I see the SharePoint online admin screen. So I may not be too crazy after all. I have a few SharePoint site already pre-provisioned for me. Then it dawned on me that I am here to learn SharePoint online development. So I go back to this link:
http://dev.office.com/devprogram
Here you will see a section for Ready to Jump Right In. Well I created the accounts, so I thought I am just about ready. And I clicked. I am a SharePoint guy. So when I saw: SharePoint Add-Ins (formerly known as Apps for SharePoint), it caught my attention. So I clicked on the Get Started link. This brought me to the default page:
https://msdn.microsoft.com/EN-US/library/office/fp142379.aspx
that says : Get started creating SharePoint-hosted apps for SharePoint. So I see this section for: Set up your dev environment and I get excited. I thought Office 365 development subscription will give me some kind of on-line development environment. And then I see this line:
•If you don’t already have Visual Studio 2013 or later installed, install it using the instructions at Install Visual Studio. We recommend using the latest version from the Microsoft Download Center.
Wait, where shall I install it? On my office machine with Windows 7 on hardly any RAM? What if my office does not like me any more? I will sit @ home and Starbucks taking interviews and doing what else? So I remembered about this article:
http://blogs.msdn.com/b/sharepointdev/archive/2013/09/26/create-sharepoint-2013-development-environments-quickly-on-azure.aspx
Now this is an article from 2013. After two years have passed, you will find a few changes and you have to find your way through the forest of unknown roadblocks. But let us give it a try. On your Office Portal Admin page:
https://portal.office.com/Admin
you will see a link on the left navigation called Azure AD. I clicked on that. This will take you to:
https://manage.windowsazure.com
And then will make you create a separate Azure account. Somewhere on this screen it will tell you that you have certain $$ amount of free Azure credit. I already told that I like free stuff. So I created my account. However, here you have to provide your credit card. And remember, I heard somewhere that I can get Office 365 developer subscription for about $8 a month. I don’t mind that for learning some cool development skills. But I told myself one thing, if I provision and logon to an Azure VM, I gotto remember to turn that off as soon as I am done. You will eventually see a screen like:
Capture4
Select Virtual Machine and +New sign towards the bottom. Select From Gallery and select a Visual Studio track that you like. Once selected, it will provide you a machine/ dns name. Keep good note of that because you will need that information while rdp-ing onto the machine. Once the machine is provisioned, you will create a user and credentials. You will use this user for rdping into the vm. For me the dns name was: SoumyaVM1.cloudapp.net
Once the machine is provisioned and started, you will click the connect button below. I could not run or save the rdp file in IE11. So I tried Chrome to download the rdp file onto my laptop. While prompted for userid/ credentials, I am providing:
SoumyaVM1.cloudapp.net\myusername
and credentials.
Next onto my dev learning journey.

Capture PowerShell console output in a file – Start-Transcript

Tags

, ,

This is sort of a self note. This information is in many places. But I struggled to meaningfully search it despite knowing it is there.
Often, while running a command-let, we get a lot of results and it overruns the console window by a long shot. We can never go back up and take a look at the results from the beginning of the command’s execution.
In order to simultaneously log results in a text file, you can start it by:

PS F:\> Start-Transcript
Transcript started, output file is C:\Users\********\Documents\PowerShell_transcript.**********.txt
PS F:\>

There are ways to define the output file also. You may refer to the detailed help by:
Get-Help Start-Transcript
Examples of scenarios it may help are Get-SPSite | Limit All where there may be so many results that it will overrun the console window.

restore-spsite failed by DirectoryNotFoundException

Tags

,

We wanted to back up site collections from PRODUCTION to DEV via PowerShell Backup-SPSite and Restore-SPSite and encountered this problem:
restore-spsite failed by DirectoryNotFoundException
ULS Logs suggested the following:

Could not deserialize site from E:\***\***\***.bak . Microsoft.SharePoint.SPException: Schema version of backup 15.0.4569.1000 does not match current schema version 15.0.4420.1017     at Microsoft.SharePoint.SPSite.Restore(String filename, Boolean isADMode, Boolean& readOnlyMode, Boolean& hadWriteLock)
Resolution:
So from the above we at least had the idea that SharePoint is reporting some kind of version mismatch. But from CA is was apparent that this is not configuration mismatch. So it has to be a content database issue. We first determined what database the target site collection is going to be at. This can only be done by creating the target site collection before hands. And then we tried a restore. The restore failed. Now we upgraded the entire database by:

Upgrade-SPContentDatabase DatabaseName
It took a while but it upgraded the database.
After this we tried the restore again with force parameter enabled. And it worked this time.

For details, please look into my forum post:
https://social.technet.microsoft.com/Forums/en-US/a57b742c-ca20-4471-bdab-6edc1fea18f1/restorespsite-failed-by-directorynotfoundexception?forum=sharepointadmin