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

Tuesday, October 23, 2012

SQL Query: List all SQL Databases except System DB's


SELECT [name]
FROM master.dbo.sysdatabases
WHERE dbid > 4

Wednesday, October 3, 2012

Get Content DB Size of all Content DBs as "Report"

Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue 
$cdbs = get-spcontentdatabase
$sum = 0
Write-host "****************************************************" -foregroundcolor white
foreach ($cdb in $cdbs)
 {
 $size = [System.Math]::round(($cdb.DiskSizeRequired/1024/1024/1024),2)
 write-host $size "GB" "--->" $cdb.name   -foregroundcolor green
 $sum = $sum + $cdb.DiskSizeRequired
 }
Write-host "****************************************************" -foregroundcolor white
write-host "Total Space Used:" ($sum/1024/1024/1024/1024)"TB"  -foregroundcolor red
write-host "Total Space Used:" ($sum/1024/1024/1024)"GB"  -foregroundcolor red
Write-host "****************************************************" -foregroundcolor White

IIS ApplicationHost.config - Request Filtering (e.g. Filetype *.mdb)

If you want to allow a filetype like e.g. *.mdb it's not enough to allow that type within SharePoint.
You've to allow it as well within IIS (if request filtering is enabled)

That can be done manually




OR: if you've multiple IIS Servers within your SharePoint Farm via PowerShell Script:


$servers = "server1","server2","server3","server4"
foreach ($server in $servers)
 {
 

 Invoke-Command -computername $server -ScriptBlock {
 
        import-module webadministration
 
        Function Enable-IISFileExtension
        {
            PARAM(
                 $ConfigFile,
                 $FileType,
                 $Flag
        
                 )
            $xml = [XML](Get-Content -Path $ConfigFile -ErrorAction STOP)
            $item = $xml.configuration."system.webServer".security.requestFiltering.fileExtensions.add | Where-Object {$_.fileExtension -match "$FileType"}
            $item.allowed = $Flag
            $xml.Save($ConfigFile)
   
            return $xml.configuration."system.webServer".security.requestFiltering.fileExtensions.add | Where-Object {$_.fileExtension -match "$FileType"}
   
        }
        Enable-IISFileExtension -ConfigFile "C:\Windows\System32\inetsrv\config\applicationHost.config" -FileType ".mdb" -Flag "True"
 
 
  Exit-PSSession
  }
 } 



Tuesday, October 2, 2012

The site is not valid. The 'Pages' document library is missing.

ULS Log tells me that:
The site is not valid. The 'Pages' document library is missing. ......

Solution to this problem was really simple.
I've found a blogentry on blogs.technet.com, which tells me to update the "PAGES ID", and it worked well.


$web = get-spweb "http://site-collection/path-to-affected-site"
$correctId = $web.Lists["Pages"].ID
$web.AllProperties["__PagesListId"] = $correctId.ToString()
$web.Update()

$web.AllProperties["__PublishingFeatureActivated"] = "True"
$web.Update()

Thursday, August 2, 2012

What's new in SharePoint 2013 (SP15)

Dear all,
I've found a really exciting Site where some new SharePoint features gets introduced.

http://technet.microsoft.com/en-us/sharepoint/fp142374.aspx

At the following Link, you'll find some training modules for IT PROs
http://technet.microsoft.com/en-US/sharepoint/fp123606

As i'm configuring at the moment a LAB environment , I'm going to post some new Issues/Solutions very soon.