Feeds:
Posts
Comments

In Microsoft flow there is no built in action to add a user to a SharePoint group. One way to achieve this is to use the “Send HTTP request to SharePoint”

sendhttprequest

in this action you need to

  1. Set the URL of the Site
  2. Set method to “POST”
  3. URI set to “_api/web/sitegroups({GROUPID})/users”, example: _api/web/sitegroups(10)/users
  4. Add header with key=”accept” and value = “application/json;odata.metadata=none”
  5. Add header with key =”content-type” and value = “application/json”
  6. Set the Body to be {‘LoginName’:’i:0#.f|membership|[EMAIL ADDRESS]’}, example: {‘LoginName’:’i:0#.f|membership|john.doe@domain.onmicrosoft.com’}

It would look like this

sendhttprequest2

 

This is tested with a SharePoint online connection but assume might work with on premise SharePoint as well.

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/

Newly released from Microsoft AI Lab, a tool to convert handwritten mockups into valid html code. Simply upload an image and  get HTML markup.

GitHub link: https://github.com/Microsoft/ailab/tree/master/Sketch2Code

a short YouTube video overview: https://www.youtube.com/watch?v=V6pqqPPHyYM

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);
}
}

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

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);

 

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