Wednesday, May 29, 2013

! ! ! MY NEW BLOG ON TECHNET ! ! !

Dear all,
due to I'm working for Microsoft Austria I have the possibility to create a TechNet Blog.

So all my new blogposts will be there

 
You also will find some German content on
 
This Is a Blog of the SharePoint ALPS Community, which means SharePoint PFE's from Switzerland and Austria.

very best regards for reading my blog and giving me some feedback.
best regards
Thomas


Tuesday, May 14, 2013

Clear SharePoint Config Cache with PowerShell


Add-PSSnapin -Name Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

Stop-Service SPTimerV4
$folders = Get-ChildItem C:\ProgramData\Microsoft\SharePoint\Config
foreach ($folder in $folders)
    {
    $items = Get-ChildItem $folder.FullName -Recurse
    foreach ($item in $items)
        {
            if ($item.Name.ToLower() -eq "cache.ini")
                {
                    $cachefolder = $folder.FullName
                }
               
        }
    }
$cachefolderitems = Get-ChildItem $cachefolder -Recurse
    foreach ($cachefolderitem in $cachefolderitems)
        {
            if ($cachefolderitem -like "*.xml")
                {
                   $cachefolderitem.Delete()
                }
       
        }
       
$a = Get-Content  $cachefolder\cache.ini
$a  = 1
Set-Content $a -Path $cachefolder\cache.ini

read-host "Do this on all your SharePoint Servers - and THEN press ENTER"
start-Service SPTimerV4

Add listitems with PowerShell

$weburl = "http://mysharepoint"
$listname = "TestList"
$a = "Text1"
$b = "Text2"
$c = "Text3"



Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue 
$web = Get-SPWeb -Identity $webUrl
$list = $web.Lists[$listname]
$newItem = $list.items.add()
$newitem["Title"] = $a
$newitem["Custom_Column1"] = $b
$newitem["Custom_Column2"] = $c

$newitem.update()

Wednesday, May 8, 2013

List all Databases from your SQL Server via PowerShell

I've created this script, because some guys wanted to know which DBs are available.
It can be used to e.g. mount some unmounted contentdatabases.

-----------

function ListAllSQLDBs {param ( $DatabaseServer)
if ($DatabaseServer -eq $null)

    $DatabaseName=   "master"
    $QueryString = "EXEC sp_databases"

    $SQLDBs = New-Object system.Data.DataTable
    $col1 = New-Object system.Data.DataColumn DBName
    $SQLDBs.columns.add($col1)
    function ADD_TO_SQL_DB_TABLE
    {param ( $DBName)
        $newRow = $SQLDBs.NewRow()
     $newRow.DBName = $DBName
        $SQLDBs.rows.add($newRow)
     }

    [void][reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo")
    $conn = New-Object Microsoft.SqlServer.Management.Common.ServerConnection($DatabaseServer)
    $conn.DatabaseName = $DatabaseName
    $r = $conn.ExecuteReader($QueryString)
    While ($r.Read())
    {
       $Name = $r.GetValue(0);
       ADD_TO_SQL_DB_TABLE -DBName $Name
    }
    $r.Close()
    Write-Output $SQLDBs
}

#functioncall
ListAllSQLDBs -DatabaseServer "mydbserver"

Tuesday, May 7, 2013

SharePoint Crawl Log Error: “The SharePoint item being crawled returned an error when attempting to download the item” .. for eg. *.aspx files

After some research I found a solution for that problem

Open Regedit on your search server/s

Navigate to this registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Global\Gathering Manager

Change Value "UserAgent" from  "MSIE 4.01" to "MSIE 8.0"

Restart the SharePoint Search Service.

Open a SharePoint PowerShell

Get-SPSessionStateService

If this returns false then we need to deploy one

Enable-SPSessionStateService -DatabaseName “NameOfDatabase”

Monday, May 6, 2013

Delete Webs Recursive with PowerShell


$web = Get-SPWeb "http://localhost/sites/webwithsubwebs/"

function RemoveSPWebRecursively([Microsoft.SharePoint.SPWeb] $web)
{
 
    $subwebs = $web.GetSubwebsForCurrentUser()
   
    foreach($subweb in $subwebs)
    {
        RemoveSPWebRecursively($subweb)
        $subweb.Dispose()
    }
    Remove-SPWeb $web -Confirm:$false
}


RemoveSPWebRecursively $web

Partial "Index Reset"

This script will remove and re-add your content source's start addresses.
SharePoint will more or less rebuild the index for these sources, when a full crawl is started.


$sourceName = "Local SharePoint sites"

$SSA = Get-SPEnterpriseSearchServiceApplication
$source = Get-SPEnterpriseSearchCrawlContentSource -Identity $sourceName -SearchApplication $SSA
$startaddresses = $source.StartAddresses | ForEach-Object { $_.OriginalString }
$source.StartAddresses.Clear()
ForEach ($address in $startaddresses ){ $source.StartAddresses.Add($address) }

Tuesday, April 30, 2013

Check a Lists BrowserFileHandling. --> Set it to Strict or Permissive

Add-PSSnapin -Name Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

$problem_web = "http://mysharepoint/"
$problem_list = "Tasks"
    
 $set_bfh_to = "strict"
 #$set_bfh_to = "permissive" 
                                                
$web=get-spweb $problem_web
$list=$web.Lists[$problem_list]         
write-host "BrowserFileHandling Setting:"$list.BrowserFileHandling -ForegroundColor GREEN



$web=get-spweb $problem_web
$list=$web.Lists[$problem_list]
$bfh_old = $list.BrowserFileHandling      
$bfh_new = $list.BrowserFileHandling =  $set_bfh_to
write-host "BrowserFileHandling Setting set from $bfh_old to $bfh_new."-ForegroundColor GREEN
$list.Update()

Tuesday, March 5, 2013

SharePoint Social Rating Updates moreoften than once per hour

These two TimerJobs are responsible for Social Rating Updates:
(http://technet.microsoft.com/en-us/library/cc678870.aspx)
  • User Profile service application - social data maintenance
    • Aggregates social tags and ratings and cleans the social data change log.
  • User Profile service application proxy - social rating synchronization
    • Synchronizes rating values between the social database and content database.
Per default these Jobs are running hourly. You can modify these jobs to run more than once an hour up to once per minute.


Performance Considerations when you let this timerjob run e.g.: once per minute:
 --> You have to monitor especially the performance of your social database, because this is the single point where every rating information is inserted.


 How to find out how long these TimerJobs are currently running:

$social_timer = get-sptimerjob | ? {$_.Name -like "*social*"}

foreach ($timer in $social_timer)
   {
    write-host "Duration of TimerJob:" $timer.name "(hh:mm:ss,ms)" -foregroundcolor yellow
   
     $historyentries = $timer.historyentries
     foreach ($hist in $historyentries)
     {
        $duration = $hist.EndTime - $hist.StartTime
        write-host $duration.hours":"$duration.minutes":"$duration.seconds","$duration.milliseconds -foregroundcolor green
     }
   }

AntiVirus for SharePoint 2013 - Status 05.Mar 2013


Microsoft's Position on Antivirus Solutions for Microsoft SharePoint Portal Server
<http://support.microsoft.com/kb/322941>



Now the "good" news from Spencer Harbar:

http://www.eset.com/beta/sharepoint/ = currently beta but RTM coming soon (currently the one and only AV for SharePoint which is supported)

SQL Query: Shrink all DBs

DO NOT USE THIS SCRIPTS WITHIN YOUR PROD ENVIRONMENT!!!!

sp_MSForEachDB '
backup log [?] to disk = ''nul'''
go

sp_MSForEachDB '
use [?];
checkpoint
'
go


sp_MSForEachDB '
USE [?];
DBCC SHRINKFILE (N''?_log'' , 1024)
'
go


PowerPoint: Link within Email -> Check out do not work properly

This KB describes the problem exactly and brings up a solution: http://support.microsoft.com/kb/2661910

But in a few sentences.
There are two ways to solve that problem:
  1. add a RegKey to all Clients
    Windows Registry Editor Version 5.00
    [HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/vnd.ms-powerpoint.presentation.12]
    "Extension"=".pptx"
  2. Set the Browser File Handling setting within WebApplication settings to permissive instead of strict.
Here's a little more information to "Browser File Handling" (what is it)
http://social.technet.microsoft.com/wiki/contents/articles/8073.sharepoint-2010-and-2013-browser-file-handling-deep-dive.aspx

Thursday, January 3, 2013

max degree of parallelism

..Has to set to "1" on SQL Servers for SharePoint environments

Best practices: http://technet.microsoft.com/en-us/library/hh292622(v=office.14).aspx
Storage and SQL Capacity http://technet.microsoft.com/en-us/library/cc298801(office.14).aspx

Calculate and Set Distributed Cache Size

#calculation from: http://technet.microsoft.com/en-us/library/jj219613.aspx
$membanks =get-wmiobject Win32_PhysicalMemory
$sum = 0
$i=1
foreach ($membank in $membanks)
{
 write-host "Capacity Memory $i = " ($membank.capacity/1024/1024)
 $sum = ($membank.capacity/1024/1024) + $sum
 $i=$i+1
}

write-host "Sum of Memory = " $sum

$cachesize = ($sum - 2048)/2
if ($cachesize>16384)
 {
  $cachesize=16384 #not more than 16GB
 }

write-host "Distributed Cachesize will be updated to: " $cachesize
Update-SPDistributedCacheSize -CacheSizeInMB $cachesize