Collaboration-2-Go


Lösungen und Software-Entwicklung im Collaboration Umfeld, insbesondere Microsoft SharePoint, Microsoft Exchange und Microsoft Office.

Support


Mobil: +49 (152) 53 97 78 79
Mail: service@collaboration-2-go.de
Weitere Kontaktmöglichkeiten: Kontaktseite
Dekoration: Köln



Activate Feature using CSOM
Created: 19.04.2015
Categories: SharePoint 2013; SharePoint Development

Add references to Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime.

Code:

string url = "https://sharepoint/sites/teamsite";
string domain = "myDomain";
string login = "myLogin";
string pwd = "myPassword";
// feature id for MySite Newsfeed webpart:
Guid feature = new Guid("6928B0E5-5707-46a1-AE16-D6E52522D52B");

using (var ctx = new ClientContext(url))
{
    ctx.AuthenticationMode = ClientAuthenticationMode.Default;
    ctx.Credentials =
      new System.Net.NetworkCredential(login, pwd, domain);
    var features = ctx.Site.Features;
    ctx.Load(features);
    ctx.ExecuteQuery();
    features.Add(feature, true, FeatureDefinitionScope.None);
    ctx.ExecuteQuery();
}


This way you I'm able to activate hidden features or start a bulk activation.
    

Post a Comment!


Upload Document to a SharePoint Library
Created: 15.03.2015
Categories: PowerShell; SharePoint 2013

Upload Document to a SharePoint Library:


$destinationUrl = "https://sharepoint/sites/teamsite/documents"
$file = get-childitem "e:\tmp\document.txt"

$webclient = New-Object System.Net.WebClient
$webclient.UseDefaultCredentials = $true
$webclient.UploadFile($destinationUrl + "/" + $file.Name, "PUT", $file.FullName)


In case you don't want to use integrated security you have to set the credentials.
    

Post a Comment!


Restart Worker Processes and SPTimerV4 in Farm
Created: 13.12.2014
Categories: PowerShell; SharePoint 2013

Restart IIS worker processes and SPTimerV4 in SharePoint Farm


add-pssnapin microsoft.sharepoint.powershell
$spserver = get-spserver | ?{$_.role -eq "Application"}
foreach ($server in $spserver)
{
  $name = [string]::concat("\\", $server.name)
  write-host "Performing IIS Reset on Server:"$server.name
  iisreset $server.Name

  write-host "Stopping SPTimerV4 on Server:"$server.name
  $stat = sc.exe $name stop sptimerv4
  $stat = sc.exe $name query sptimerv4
  while ($stat -match "STOP_PENDING")
  {
    write-host "Stopping"
    $stat = sc.exe $name query sptimerv4
    start-sleep 4
  }

  write-host "Starting SPTimerV4 on Server:"$server.name
  $stat = sc.exe $name start sptimerv4
  $stat = sc.exe $name query sptimerv4
  while (-not $stat -match "RUNNING")
  {
    write-host "Starting"
    $stat = sc.exe $name query sptimerv4
    start-sleep 4
  }

  write-host "SPTimerV4 started on Server:"$server.name
}

    

Post a Comment!


SharePoint Lists and Coloured Rows
Created: 26.08.2014
Categories: SharePoint 2013; SharePoint Development

If you want to use coloured rows in SharePoint lists,

  • copy code to a file called 'HighlightRows.js'

  • Remove spaces in RenderColour between '< and a' and '< and img'
  • (stupid blog software)

  • upload file to a site collection and remember the path

  • add calculated column called 'Colour' to your list

  • Provide colour in this field, e.g. =IF(Priority="High";"rgba(255, 0,0,0.5)";IF(Priority ="medium";"rgba(255, 255,0,0.5)";"#ffffff"))

  • Include colour field in all views

  • Bind all views to JS in the ListView webpart settings, e.g. to ~sitecollection/style%20library/HighlightRows.js



Coloured SharePoint list

HighlightRows.js:

(function () {
  var overrideCtx = {};
  overrideCtx.Templates = {};
  overrideCtx.OnPostRender = [ HighlightRowOverride ];
  overrideCtx.Templates.Fields={ "Colour":{"View":RenderColour}}
  SPClientTemplates.TemplateManager.RegisterTemplateOverrides
   (overrideCtx);
})();

function RenderColour(ctx) {
  var link = ctx.displayFormUrl +
    "&ID=" + ctx.CurrentItem.ID +
    "&source=" +
    encodeURIComponent(window.location.href);
  var text = "< a class='ms-core-suiteLink-a' href='" +
    link +
    "'>< img src='/_layouts/15/images/icgen.gif'>";
  return text;
}

function HighlightRowOverride(inCtx) {
  for (var i = 0; i < inCtx.ListData.Row.length; ++i) {
    var listItem = inCtx.ListData.Row[i];
    var iid = GenerateIIDForListItem(inCtx, listItem);
    var row = document.getElementById(iid);
    if (row != null) {
      row.style.backgroundColor = listItem.Colour;
    }
  }
  inCtx.skipNextAnimation = true;
}

    

Post a Comment!


SharePoint and Remote Blob Storage - Performance Considerations
Created: 14.02.2014
Categories: SharePoint 2013

In our SharePoint 2013 test farm we installed RBS. Unfortunately the performance is very bad. We used an RBS system from a different manufacturer than Microsoft.

Average download times for a 14 MB video file and a 1 MB Word document:
File SizeFile stored in SQL ServerFile stored in RBS
14 MB4,06 sec30,3 sec
1 MB0,79 sec2,8 sec

This is pretty bad. Is seems that the performance regression is related to the new Shredded Storage setting. If we increase the setting up to 1 GB we get the following results:
File SizeFile stored in SQL ServerFile stored in RBSAdjusted Shredded Storage
14 MB4,06 sec30,3 sec3,44 sec
1 MB0,79 sec2,8 sec0,77 sec

The manufactorer was surprised in the first discussion but confirmed the results later. He told us that we have to disable the shredded storage.
      
Here you can see the results in Visual Studio:
Measuring native SQL Server
Measuring RBS
Measuring RBS with disabled shredded storage
      
First tests with native RBS coming with SQL Server 2012 don't show this downshift. Maybe we will follow this path.
  

Post a Comment!


Newsfeed Administrator - Lock and delete Newsfeed Posts
Created: 21.01.2014
Categories: SharePoint 2013

Newsfeed Administrator - Lock and delete Newsfeed Posts:
  • Open Central Admin
  • Open Application  Management
  • Click next to "User Profile Service" without changing the page but highlighting the service

    User Profile Service
  • Click button "Administrators" in ribbon

    Click on button 'Administrators'
  • Add user
  • Check permission "Manage Social Data"
    Check 'Manage Social Data'


Original:
Original


Result:
Result


(Additional menus: lock discussion, delete)
    

Post a Comment!


Add Followers to a SharePoint 2013 Site
Created: 11.01.2014
Categories: SharePoint 2013; SharePoint Development; PowerShell

Add Followers to a SharePoint 2013 Site using PowerShell:

$followedSite = „https://sharepoint/sites/news“
$loginName = „roloff“

$profile = $upm.GetUserProfile($loginName)
$manager = New-Object Microsoft.Office.Server.Social.SPSocialFollowingManager($profile)

$actorInfo = New-Object Microsoft.Office.Server.Social.SPSocialActorInfo
$actorInfo.ContentUri = $followedSite
$actorInfo.ActorType = 2 # SPSocialActorType.Site
$manager.Follow($actorInfo)

    

Post a Comment!


Create SharePoint 2013 MySites
Created: 10.01.2014
Categories: SharePoint 2013; SharePoint Development; PowerShell

Create SP2013 MySites using an AD group and PowerShell:

$members = Get-ADGroupMember -Identity $adgroup -Recursive | sort name

foreach ($member in $members)
{
if ($upm.UserExists($member.SamAccountName))
{
  $profile = $upm.GetUserProfile($member.SamAccountName)
  $perssite = $profile.PersonalSite

  if ($perssite -eq $null)
  {
    $profile.CreatePersonalSite(1031)

    $perssite = $profile.PersonalSite
    if ($perssite -eq $null)
    {
      # do some error handling
    }
  }
}
}

    

Post a Comment!


SharePoint Database Size
Created: 09.01.2014
Categories: SharePoint 2013; SharePoint Development; PowerShell

SharePoint Database Size using PowerShell:

Get-SPDatabase |
  where-object { $_.TypeName -eq "Content Database" } |
  select Displayname,
  @{Name="Mbytes";Expression={$_.DiskSizeRequired/ 1Mb}}


Please note: TypeName is localized, e.g. use "Inhaltsdatenbank" in a German farm.
    

Post a Comment!


Multiple Default Values for a Choice Column
Created: 26.11.2013
Categories: SharePoint 2013

In order to define multiple default values for a choice column just use a calculated default value:

=";#choice 1;#choice 2;#choice 3;#"

    

Post a Comment!


Rename SharePoint MySite Blog
Created: 16.11.2013
Categories: SharePoint 2013; SharePoint Development; PowerShell

Want to rename your MySite blogs using PowerShell since all MySite blog names are "Blog"?


# URL to your MySite web application
$MySiteWebUrl = "https://mysite.collaboration-2-go.net"
      
# where to find users in the AD
$searchbase="DC=collaboration-2-go,DC=net"
      
# required if server domain and user domain are different
$dc="my_domain_controller"
      
# required if server language is English and
# MySite language is different
$culture = "de-DE"

$webapp = Get-SPWebApplication -identity $MySiteWebUrl
[System.Threading.Thread]::CurrentThread.CurrentUICulture =
  $culture
        
foreach ($site in $webapp.Sites)
{
  # Get Active Directory Information
  $login = $site.Owner.LoginName
  if ($login.contains("\"))
  {
    $login = $login.substring($login.indexof("\") + 1)
  }
        
  $ldapfilter = "(SamAccountName=" + $login + ")"
  $aduser = Get-ADUser -LDAPFilter $ldapfilter
    -SearchBase $searchbase -Server $dc
  $displayName = $aduser.GivenName + " " + $aduser.Surname
      
  if ($displayName -eq " ")
  {
    $displayName = $site.owner.DisplayName
  }
      
  if ($site.RootWeb.WebTemplate -eq "SPSPERS") # ignore MySite host
  {
    # more sophisticated approach is possible but
    # I'm not sure about the blog URL
    foreach ($web in $site.AllWebs)
    {
      if (($web.WebTemplate -eq "BLOG") -and
        ($web.Title -eq "Blog"))
      {
        $title = "Blog von " + $displayName
        $web.Title = $title
        $web.Update()
      }
          
      $web.Dispose()
    }
  }
        
  $site.Dispose()
}

      
If you don't set the culture SharePoint changes to English title only.
    

Post a Comment!


SharePoint Blog Layout
Created: 16.11.2013
Categories: SharePoint 2013; SharePoint Development; PowerShell

Want to apply different blog layouts using PowerShell?
      
Sample: Standard Layout:
Blog Beitrag Layout Standard

Sample: Framed Layout:
Blog Beitrag Layout Umrahmt

$web = Get-SPWeb https://sharepoint/sites/blog
write-host $web.Properties["ms-blogs-skinid"]
$web.Properties["ms-blogs-skinid"] = 1
$web.Properties.update()

Valid values for ms-blogs-skinid: 1, 2, 3
    

Post a Comment!


Collecting ULS Data
Created: 29.07.2013
Categories: SharePoint 2010; SharePoint 2013

Samples for collecting ULS data from all servers:

Collect all data:
Merge-SPLogFile -Path C:\tmp\FarmLog.log

Collect all data with a correleation ID (remove line break):
Merge-SPLogFile -Path C:\tmp\FarmLog.log
  -Correlation b572479c-ce57-10ce-c901-ce456a0284dc


Collect all data within a timeframe (adjust regional time format, remove line break):
Merge-SPLogFile -Path C:\tmp\FarmLog.log
  -StartTime "28.07.2013 00:00" -EndTime "28.07.2013 23:59"

    

Post a Comment!


Login as a different User
Created: 23.07.2013
Categories: SharePoint 2013

If you want to use the SP2010 functionality 'Login as a different User'
you can use the following link:
      
http://yourhost/_layouts/closeConnection.aspx?loginasanotheruser=true
      
There is no need to adjust the Welcome.ascx as suggested in many blogs.
      
Please remember that other client applications (e.g. Word) are not aware of this different
login but provide their own authentication.
    

Post a Comment!


SharePoint Warm-Up
Created: 19.07.2013
Categories: SharePoint 2010; SharePoint 2013

If you want to start your SharePoint web applications you can use the following
VisualBasic script as a warm-up for SharePoint. The code copies the host file
in order to reach each web front end server.
server1: "host-server1"
server2: "host-server2"
Plus "host-original" in order to move back
      
VBS Code:

' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' URL List

Dim urls(3)
urls(1)="https://portal/sites/project1"
urls(2)="https://portal/sites/project2"
urls(3)="https://portal/sites/project3"

Dim servers(2)
servers(1) = "server1"
servers(2) = "server2"

Dim PingReply
PingReply = "Reply from"

Dim TargetUrl
TargetUrl = "portal"

Dim outFile
outFile="c:\WarmUp\WarmUp2013.log"

' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'On error resume next

' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Code
dim fso
dim startTime
startTime = Now

'DeleteLog
AddToLog "------------------------------------------------"

set fso = CreateObject("Scripting.FileSystemObject")

For Each server in servers
  If server <> "" Then
    AddToLog "---------------- " & UCase(server)
    hostfile = "C:\Windows\System32\drivers\etc\hosts-" & server
    fso.CopyFile hostfile, "C:\Windows\System32\drivers\etc\hosts"
    PingResult TargetUrl
    WarmUp()
  End If
Next

AddToLog "---------------- RESET"
fso.CopyFile "C:\Windows\System32\drivers\etc\hosts-original", "C:\Windows\System32\drivers\etc\hosts"
PingResult TargetUrl
set fso = Nothing

AddToLog "---------------- Summary"
minTime = UBound(urls) * UBound(servers) * 5
duration = datediff("s", startTime, now)
AddToLog "URLs: " & UBound(urls)
AddToLog "Minimal Time: " & minTime
AddToLog "Duration (s): " & duration
If duration > (minTime + 5) Then
  AddToLog "Warning!"
End If
AddToLog "------------------------------------------------"

' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Subs

sub WarmUp()
  dim ie
  set ie = CreateObject("InternetExplorer.Application")
  ie.Visible = 0

  For Each u1 In urls
    if u1 <> "" then
      AddToLog u1
      ie.Navigate2 u1
      WScript.Sleep(5000)
      Do while IE.readystate <> 4
      loop
    end if
  Next

  ie.Quit
  set ie = Nothing
end sub

sub DeleteLog()
  outFile="c:\svn\WarmUp2013.log"
  Set objFSOFile=CreateObject("Scripting.FileSystemObject")
  objFSOFile.DeleteFile outFile
end sub

sub AddToLog(txt)
  set objFSOFile=CreateObject("Scripting.FileSystemObject")
  set objFile = objFSOFile.OpenTextFile(outFile, 8, True)
  objFile.Write Now & " - " & txt & vbCrLf
  objFile.Close
  wscript.echo txt
end sub

sub PingResult(host)
  dim objShell
  dim objExec
  set objShell = CreateObject("WScript.Shell")
  set objExec = objShell.Exec("ping -n 1 -w 1000 " & host)
  pr = objExec.StdOut.ReadAll
  pr = mid(pr, InStr(pr, PingReply))
  pr = left(pr, InStr(pr, ":") - 1)
  AddToLog pr
  set objShell = Nothing
  set objExec = Nothing
end sub

You can use the script as a scheduled task. Use an account that has read access in the sites.

Alternative: Use IIS8 setting "AlwaysRunning" instead.
Not tested yet but this sounds promising: Post by Trevor Seward
    

Post a Comment!


Site Archivar for SharePoint
Created: 10.05.2013
Categories: Collaboration-2-Go; SharePoint 2010; SharePoint 2013

Our third product is ready to buy: Site Archivar for SharePoint


Site Archivar for SharePoint


Site Archivar for SharePoint


Site Archivar for SharePoint
    

Post a Comment!