Feeds:
Posts
Comments

Archive for the ‘Tips’ Category

When trying to install SP2013 on a windows 2012R2 or 2016 you may get the error : Error: The tool was unable to install Application Server Role, Web Server (IIS) Role

A quick fix might be to go to C:\Windows\System32\ , look for ServerManager.exe, make a copy and name it ServerManagerCMD.exe as this is the file that the SP prereqs is trying to call

Reference: http://www.someshinyobject.com/posts/server-2012-r2-and-sharepoint-2013-the-tool-was-unable-to-install-application-server-role-web/

Read Full Post »

In order to replace a text in any section of the header or the footer of a word document, you can use this snippet

doc = Document Object

foreach (Section sec in doc.Sections)
{
foreach (HeaderFooter fot in sec.Footers)
{
fot.Range.Find.Execute(FindText: loc.Key, ReplaceWith: loc.Value,
Replace: WdReplace.wdReplaceAll);
}
}

Read Full Post »

I had a case of an IIS site that had link to a local ODT file (Office Document Text, used by Open office and star office).

Anyone clicking on this link was getting a 404 error, file not found. I made sure the url is correct, the file exists where it is supposed to be, etc..

After some investigation, it turned out that this file did not have its MIME type defined in IIS. As a result IIS was not serving an unknown MIME type: https://support.microsoft.com/en-us/help/326965/iis-6-0-does-not-serve-unknown-mime-types 

To fix this issue, simply add the MIME type to the designated site

  1. Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).
  2. In Features View, double-click MIME Types.
  3. In the Actions pane, click Add.
  4. In the Add MIME Type dialog box, type a file name extension in the File name extension text box. For example, type .xyz.
  5. Type a MIME type in the MIME type text box. For example, type application/octet-stream.
  6. Click OK.

Ref: https://technet.microsoft.com/en-us/library/cc725608%28v=ws.10%29.aspx

Read Full Post »

To have http redirects in a sharepoint we can use something like this in the web.config file

<location path=”oldpage1.htm”>
<system.webServer>
<httpRedirect enabled=”true” destination=”newpage1.html” exactDestination=”true” httpResponseStatus=”Permanent” />
</system.webServer>
</location>

One simple way of doing it using PowerShell is to use the SPWebConfigModication object.

The following script can achieve that

 

$Owner = “redirectMod”
$webApp = Get-SPWebApplication $Url

 

$modification = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$modification.Path = “configuration”;
$modification.Name = “redirect-1” ;
$modification.Sequence = 0;
$modification.Owner =$Owner;
$modification.Type = 0 # EnsureChildNode;
$modification.Value = “<location path='”+$from+”‘><system.webServer><httpRedirect enabled=’true’ destination='”+$to+”‘ exactDestination=’true’ httpResponseStatus=’Permanent’ /></system.webServer></location>”;
$webApp.WebConfigModifications.Add($modification);

$webApp.Update()
$webApp.Parent.ApplyWebConfigModifications()
do{
Start-Sleep -Seconds 2;
Write-Host “.” -NoNewline
$configJobRunning = IsWebConfigModificationJobPendingOrRunning $webApp;
}while ($configJobRunning);

 

Read Full Post »

If we need to add some URL rewrite to a SharePoint site, we can do that using some web.config settings like :

<rewrite>
<rewriteMaps>
<rewriteMap name=”Redirects”>
<add key=”/Page1.html” value=”/Page1″ />
<add key=”/Page2.html” value=”/Page2″ />
</rewriteMap>
</rewriteMaps>
</rewrite>

One way to do that Is to use SharePoint Powershell commands.

The following script achieves that:
[Microsoft.SharePoint.Administration.SPWebConfigModification] $modification = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$modification.Path = “configuration/system.webServer”;
$modification.Name = “rewrite”;
$modification.Sequence = 0;
$modification.Owner =$Owner;
$modification.Type = 0 # EnsureChildNode;
$modification.Value = “”;
$webApp.WebConfigModifications.Add($modification);

$modification = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$modification.Path = “configuration/system.webServer/rewrite”;
$modification.Name = “rewriteMaps”;
$modification.Sequence = 0;
$modification.Owner =$Owner;
$modification.Type = 0 # EnsureChildNode;
$modification.Value = “”;
$webApp.WebConfigModifications.Add($modification);

$modification = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$modification.Path = “configuration/system.webServer/rewrite/rewriteMaps”;
$modification.Name = “rewriteMap”;
$modification.Sequence = 0;
$modification.Owner =$Owner;
$modification.Type = 0 # EnsureChildNode;
$modification.Value = “”;
$webApp.WebConfigModifications.Add($modification);

$modification = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$modification.Path = “configuration/system.webServer/rewrite/rewriteMaps/rewriteMap”;
$modification.Name = “redirect-1”;
$modification.Sequence = 0;
$modification.Owner =$Owner;
$modification.Type = 0 # EnsureChildNode;
$modification.Value = “”;
$webApp.WebConfigModifications.Add($modification);

$modification = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$modification.Path = “configuration/system.webServer/rewrite/rewriteMaps/rewriteMap”;
$modification.Name = “redirect-2”;
$modification.Sequence = 0;
$modification.Owner =$Owner;
$modification.Type = 0 # EnsureChildNode;
$modification.Value = “”;
$webApp.WebConfigModifications.Add($modification);

$webApp.Update()
$webApp.Parent.ApplyWebConfigModifications()

do{
Start-Sleep -Seconds 2;
Write-Host “.” -NoNewline
$configJobRunning = IsWebConfigModificationJobPendingOrRunning $webApp;
}while ($configJobRunning);

References:

https://blog.kenaro.com/2010/09/02/add-web-config-modification-with-powershell-spwebconfigmodification/ 

 https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-rewrite-maps-in-url-rewrite-module 

Read Full Post »

One possible reason to have an error accessing a SharePoint site (page not found, 404 error) is that content database is not accessible by Pool user.

This could happen after restoring content database using SQL restore if you don’t follow the steps exactly.

In this case you will likely find in the ULS logs an error like

SqlError: ‘Cannot open database “WSS_Content_XYZ” requested by the login. The login failed.’

Quick fix: from central administration -> Manage content databases -> select the content database and check the “remove” to remove it from the farm and then add it again. when SP adds the content database back, it makes sure all required permissions are added and this could fix the problem.

Read Full Post »

When running Enable-SPFeature, you may get the weird error:

“Enable-SPFeature : The file is currently checked out or locked for editing by another user.”

 

One possible cause of this issue could be that some file(s) the are deployed by the feature could be checked out by a user.

Checking the ULS logs you could find something like

 

Instantiating module “NAMEOFMODULE”: File could not be added at URL “FILENAME.jpg: Error 689225296 99e77593-d0d4-49df-adcc-c8f8251fbb82
04/06/2017 20:53:42.02 PowerShell.exe (0x107C) 0x1334 SharePoint Foundation Monitoring b4ly High Leaving Monitored Scope (SPSqlClient). Execution Time=11589.5652 99e77593-d0d4-49df-adcc-c8f8251fbb82
04/06/2017 20:53:42.02 PowerShell.exe (0x107C) 0x1334 SharePoint Foundation General 8kh7 High The file is currently checked out or locked for editing by another user.<nativehr>0x80070021</nativehr><nativestack></nativestack> 99e77593-d0d4-49df-adcc-c8f8251fbb82
04/06/2017 20:53:42.03 PowerShell.exe (0x107C) 0x1334 SharePoint Foundation General aix9j High SPRequest.EnableModuleFromXml: UserPrincipalName=i:0).w|s-1-5-21-995927836-1113283497-4239367599-17896, AppPrincipalName= ,bstrSetupDirectory=C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\Template ,bstrFeatureDirectory=Features\ABCDEP ,bstrUrl=,bstrXML=<Module Name=”images” Path=”Style Library\images” Url=”Style Library/images” RootWebOnly=”TRUE” xmlns=”http://schemas.microsoft.com/sharepoint/”><File ReplaceContent=”True” Type=”GhostableInLibrary” Path=”favicon.ico” Url=”favicon.ico” /><File ReplaceContent=”True” Type=”GhostableInLibrary” Path= ,fForceUnghost=False ,pModuleContext=<null> 99e77593-d0d4-49df-adcc-c8f8251fbb82
04/06/2017 20:53:42.03 PowerShell.exe (0x107C) 0x1334 SharePoint Foundation General ai1wu Medium System.Runtime.InteropServices.COMException: The file is currently checked out or locked for editing by another user.<nativehr>0x80070021</nativehr>

Read Full Post »

We had a very weird issue today with a SharePoint publishing site. Some js and css files (which were deployed as part of a WSP) were not updated in the publishing zone.

When checking from the authoring zone, everything looked ok: the latest file was published and approved (was v1.0 since it was deployed as part of a solution). In the publishing site though, for end users, We were getting an older version of the file.

Tried clearing browser cache, close and open browser, use in-private browsing, resetting IIS, restarting server, restarting client machine, nothing worked.

After a lot of investigation and trials and errors, the issue turned out to be caused by the BlobCache. When we disabled the blob cache in the publishing zone, latest files started to work fine. With Blob Cache enabled, we were getting an older version.

For some reason even flush cache powershell command didnt seem to fix this issue. We had to disable the blobcache in the web.config for the publishing site and then manually delete the blob cache files. We then enabled blobcache again and things seemed to work fine.

More details about the nuts and bolts of BlobCache (long but interesting read) can be found at: https://sharepointinterface.com/2012/03/12/do-you-know-whats-going-to-happen-when-you-enable-the-sharepoint-blob-cache/ 

 

Read Full Post »

If all SharePoint sites are returning 404 errors, including Central Admin site after a fresh installation. the problem might be the IIS setting about unlisted file extensions.

To check if this is the case:

Enable IIS logs and check the sub status of the 404 error.

If the sub status is 7 (i.e. error is 404.7), then check the IIS config file located at C:\Windows\System32\inetsrv\config\applicationHost.config

look for the segment

<fileExtensions allowUnlisted="false" >
and change it to
<fileExtensions allowUnlisted="true" >

this setting (false) basically only allows IIS to return the specified file extensions and will block any other files. Setting it to true may fix the 404 error.

Read Full Post »

Problem:

The list/library template you just created by saving List or library as a template is not showing up when you try to create a new list/library based on that template.

 

One thing to check first is to go to the List templates Gallery (Site settings-> List templates under web designer galleries).

If the template in question does NOT have product Version and Feature ID assigned. Then the problem might be that the ParserEnabled property is set to false on that site.

 

Resolution:

Using PowerShell , set the ParserEnabled property to true.

$web = Get-SPWeb <url of web>
$web.ParserEnabled = $true
$web.Update()

 

Reference: https://support.microsoft.com/en-us/kb/2779729

 

Thanks to

https://social.technet.microsoft.com/Forums/sharepoint/en-US/112ac0b0-c6f0-40a7-8a03-19737c29d1e4/sharepoint-stp-template-is-missing-language-version-and-feature-id?forum=sharepointgeneralprevious

Read Full Post »

Older Posts »