Wednesday, June 20, 2012

Colorful SharePoint Calender

Never knew that you can combine multiple calenders in SharePoint 2010 to a single calender view. The function is called overlaying. Moreover you can define a color for each view, all OOB. I found this great post how you can colorize your SharePoint calender:

One drawback, which happened to me after overlaying was that the overlayed calender items could not be opened in the new SP 2010 Dialog style but only as new browser window.



Tip: If you have embeded the calender as webpart somewhere in your site, you have to actualize the view in the WebPart settings to view the colored calender.

Friday, June 8, 2012

Replace row numbers from copied code

This has nothing to do with SharePoint but I wanted to share the trick. When you copy code from some pages sometimes you have to copy the ugly row numbers, like

1: function XYZ
2:{
3:     var a = b;

You can delete these numbers easily with NotePad++ or another higher TextEditor. I use NotePad++ so I'll show you have I do that with NP.


  1. Copy the code into the editor
  2. Open the "Replace" dialog
  3. Check "Regular Expression"
  4. Enter the regular expression in "Find What" = \d*: (This can be any other regex)
  5. Enter nothing into "Replace String"




Thursday, June 7, 2012

Check Ports for Extranet SharePoint Farms with PowerShell

When you create a SharePoint Farm within an extranet you usually have to check ports to other servers within other security layers behind firewalls. Here is a simple script for a quick check. Copy this script to every SharePoint Server and modify the ip addresses. Run the script on the server to see if a port is blocked.


<#
These values can be modified
Enter the IPS of the server
Ports from http://technet.microsoft.com/en-us/library/cc262849.aspx
#>
$SERVER_APP = "xxx.xxx.xxx.xxx"
$SERVER_WEBAPPS = @("xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx")
$SERVER_DB = "xxx.xxx.xxx.xxx"
$SERVER_AD = "xxx.xxx.xxx.xxx"
$SERVER_DNS = "xxx.xxx.xxx.xxx"
$SERVER_SMTP = "xxx.xxx.xxx.xxx"
$CLIENT = "xxx.xxx.xxx.xxx" #IP of a client which should access SharePoint

$USE_KERBEROS = $false
$USE_NETBIOS = $false
$USE_SMTP = $true

# bi = bidirectional
# out = outbound
$CONNECTIONS = @(
  #SQL
  ( "out", $SERVER_APP, $SERVER_DB, "1435", "SQL" ),
  ( "out", $SERVER_WEBAPPS, $SERVER_DB, "1435", "SQL" ),  
  
  #Service Applications
  ( "bi", $SERVER_WEBAPPS[0], $SERVER_WEBAPPS[1], "32843,32844", "Service Applications" )  
  
  #HTTP
  ( "bi", $CLIENT, $SERVER_WEBAPPS, "80,443", "HTTP, HTTPS" ),      
  ( "bi", $SERVER_WEBAPPS, $SERVER_APP, "80,443", "HTTP, HTTPS" ),    

  #SMB
  ( "bi", $SERVER_WEBAPPS, $SERVER_APP, "445", "SMB" ),      
  
  #LDAP
  ( "out", $SERVER_APP, $SERVER_AD, "389, 636" , "LDAP, LDAPS"),
  
  #DNS
  ( "out", $SERVER_APP, $SERVER_DNS, "53", "DNS" )
)

#SMTP ?
if ($USE_SMTP -eq $true) {  
  $CONNECTIONS += ,( "bi", $SERVER_WEBAPPS, $SERVER_SMTP, "25", "SMTP" )
}

#KERBEROS ?
if ($USE_KERBEROS -eq $true) {  
  $CONNECTIONS += ,@( "bi", $SERVER_WEBAPPS, $SERVER_APP, "88,464", "Kerberos")
}

#NETBIOS ?
if ($USE_NETBIOS -eq $true) {  
  $CONNECTIONS += ,@( "bi", $SERVER_WEBAPPS, $SERVER_APP, "137,138,139", "NetBios")
}


<#
---------------------------
Do not touch these ones
---------------------------
#>
$LOCAL_IP = (Get-WmiObject -class win32_NetworkAdapterConfiguration -Filter 'ipenabled = "true"').ipaddress[0]

Function PingPort {
  $ip = $args[0] 
  $port = [int]$args[1]
  
  $ErrorActionPreference = "SilentlyContinue"
  $socket = new-object System.Net.Sockets.TcpClient($ip, $port)
  if ($socket –eq $null) {    
    $false
  } else {
    $socket = $null
    $true
  }
}

foreach ($conn in $CONNECTIONS) {  
  if ($conn[0] -eq "bi") {    
    $CONNECTIONS += ,@( "out", $conn[2], $conn[1], $conn[3], $conn[4] )
  }
}

foreach ($conn in $CONNECTIONS) {  
  if ( $conn[1] -is [System.Array] ) { $servers1 = $conn[1] }else{ $servers1 = @($conn[1]) }
  if ( $conn[2] -is [System.Array] ) { $servers2 = $conn[2] }else{ $servers2 = @($conn[2]) }    
  $ports = $conn[3] -split ","  
  $desc = $conn[4]
  
  foreach( $port in $ports) {
    foreach( $server1 in $servers1) {    
      foreach( $server2 in $servers2) {            
        if ($LOCAL_IP -eq $server1) {
          Write-Host "`nTesting Connection:"
          Write-Host $server1 " -> " $server2 " -> Port:" $port " [" $desc "]" -foregroundcolor yellow
          $pinged = PingPort $server2 $port
          if ( $pinged -eq $true ){
            Write-Host "Connection O.K." -foregroundcolor green
          }else{
            Write-Host "Port closed." -foregroundcolor red
          }
        }
      }
    }
  }
}