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