PowerShell 2.0 Adding Columns to Document Libries in a Site Collection.

Adding Columns to a SharePoint List across an entire Site Collection should be done like this using PowerShell (with Power GUI):
 
Note that the use of the following works with all the defaults... 
$fieldDateTime = [Microsoft.SharePoint.SPFieldType]::DateTime
$list.Fields.Add("Compliance Date",$fieldDateTime,$false) 

However, you get MORE Control over Field Attributes using this method:
$fldXml = "<Field Type='DateTime' DisplayName='Report Sign Off Date' Format='DateOnly' Name='Report Sign Off Date'/>"     
$list.Fields.AddFieldAsXml($fldXml) 
 
Both methods are used in the code block below. 
if ((Get-PSSnapin | ? { $_.Name -eq "Microsoft.SharePoint.PowerShell" }) -eq $null) {
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges( 
{
 $site =  Get-SPSite -Identity "https://mysite.com/sites/thissite"
 Write-Host "Script Started"
 [array]$ListNames = "ListA", "ListB"
 $NumberofReportsinRecordFound = $false
 $ReportSignOffDateFound = $false
 $ComplianceDateFound = $false
 foreach($web in $site.AllWebs)
 {
  #Get number if Lists rather than using foreach as we will be modifying the List
  
  for($i=0; $i -lt $web.Lists.Count; $i++)
  {
   $list = $web.Lists[$i]
   if($list.BaseType -eq "DocumentLibrary" -and $list.BaseTemplate -notmatch "Catalog")
   {
    Write-Host $web.Title
    Write-Host $list
        
    $NumberofReportsinRecordFound = $false
    $ReportSignOffDateFound = $false
    $ComplianceDateFound = $false
      
    if($ListNames -contains $list.Title)
    {
     for($j=0; $j -lt $list.Fields.Count; $j++)
     {
      $field = $list.Fields[$j]
      if($field.Title -like "*do not use*")
      {
          Write-Host "do not use deleted!"
       $list.Fields.Delete($field)
       $list.Update() 
      }
      
      if($field.Title -like "Number of Reports in Record")
      {
       $NumberofReportsinRecordFound = $true
      }
      if($field.Title -like "Report Sign Off Date")
      {
       $ReportSignOffDateFound = $true
      }
      
      if($field.Title -like "Compliance Date")
      {
       $ComplianceDateFound = $true
      }
     }
        $fieldNumber = [Microsoft.SharePoint.SPFieldType]::Number

     if(!$NumberofReportsinRecordFound){
      $list.Fields.Add("Number of Reports in Record",$fieldNumber,$false)
      $fld = $list.Fields["Number of Reports in Record"]
     }
     
     if(!$ReportSignOffDateFound){
      $fldXml = "<Field Type='DateTime' DisplayName='Report Sign Off Date' Format='DateOnly' Name='Report Sign Off Date'/>"
      $list.Fields.AddFieldAsXml($fldXml)
     }
     
     if(!$ComplianceDateFound){
      $fldXml = "<Field Type='DateTime' DisplayName='Compliance Date' Format='DateOnly' Name='Compliance Date'/>"
      $list.Fields.AddFieldAsXml($fldXml)
     }
     $list.Description = "Inspection Reports"
     $list.Update()
    }
   }
  }
 }
 $web.Dispose()
 $site.Dispose()
 Write-Output "Script Ended"
}
)

Databases running in compatibility range, upgrade recommended.

When you apply a hot fix to SharePoint 2010 you need to run a command to complete the patch otherwise you will see this message in Central Admin "Databases running in compatibility range, upgrade recommended" under Upgrade and Migration -> Review database status, under the Status column.

To resolve this issue you need do the following.
1. Open an Administrative command prompt. CMD - Run as Administrator, or open the SharePoint PowerShell Command Window.
2. If running just the normal PowerShell Command Windows, change directory to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN
3. Run PSConfig.exe -cmd upgrade

More information can be found here: http://technet.microsoft.com/en-us/library/cc263093.aspx

Hotfixes/Cummulative Updates: http://technet.microsoft.com/en-us/sharepoint/ff800847.aspx#LatestUpdates

SharePoint 2010 Favicon

How to set Favicon to the SharePoint 2010 site?

SharePoint 2010 comes with a orange Favicon and it's present in SharePoint Root Folder\Template\Images [eg. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\]. Open this folder and search for favicon.ico and rename the file to FaviconBackup.ico. Now copy your favicon to this folder and make sure it's named as "favicon.ico". Now restart IIS(open Command Prompt -> IISReset), clear browser cache/temproary internet files. Close the browser and reopen then browse the SharePoint site.

If mulitple sites are hosted in same farm and need to set different favicons for different sites then we have to update Master Page Code. Open the site with SharePoint Designer 2010 and select Master pages -> v4.master. The default.master is still present in SharePoint 2010 for backward compatibility and visual upgrade. But SharePoint 2010 uses v4.master only. Now click "Edit File" link to add the favicon code. If it asks for check out, click yes and continue.

Find and change the path of favicon. Save and close (If you have checked out then you need to check in and site collection administrator has to approve it via Site Settings -> Galleries -> Master pages and page layouts -> Check in and Approve). Now reset IIS/clear browser cache and check.

SharePoint Widget Multiplies

I had this same issue and the reason why it multiplies is because it's in a Content Editor WebPart (CEWP) as a <Script> when it should be Linked to a document in a library. Basically, copy the <Script> into a Notepad document then save it as Widget.htm on your desktop. Then create a New Document Library called Widgets (sounds good to me!), then add the Widget.htm file to the library. Click in the document and you will see the widget render as expected. Then the copy the URL from the address bar. Add a new CEWP to your web page and then paste the URL into the link section! BTW, I would not include http://mysite in the link, just use everything else it.

Now your widget is safely rendered and it will NOT multiply like magic bunnies.

Hope this helps someone out there! Oh BTW, this issue arrived to me after I migrated a 2007 to 2010 site.

Dave

SharePoint 2010 List View Videos

I have had to do some work on Data List Views recently after migrating from 2007 to 2010 since DataFormWebParts don't really work as they should in 2010, especially when it comes to the DispForm.aspx, for example, especially because (at least I found this) it would not open the DispForm.aspx page in Modal Dialog mode. Plus the New and Edit forms would not open in Modal Dialog either. So I have found a few excellent videos by Laura Rogers that helped me a lot. Basically XSLT Views Rock!

Laura Rogers - SharePoint 2010 Data View and XSLT List View:  http://www.youtube.com/watch?v=r2eODYHp73A

Laura Rogers - Creating Hyperlinks in SharePoint Designer 2010:  http://www.youtube.com/watch?v=-ZBF_J1RWis

SharePoint 2010 - Display list or library on another site:    http://www.youtube.com/watch?v=0SfpgoEUlIw

YouTube Site: http://www.youtube.com/user/WonderLaura67

Laura provides a lot of information so please replay the videos as you will pick up more and more as you put her advise to practice.

Hope this helps someone out there! I know it helped me a great deal.

Dave 

SharePoint 2010 Site is Locked

I have had this issue popup a couple times in the last 2 years and it always catches me off guard!

You notice that "all of a sudden" one day that your SharePoint Site is Locked. You can't add anything, change anything, like users or documents. It's all locked! This is usually because a Backup was stopped (or died from a server reboot!) before it was able to complete!

Simple solution that you can run at the SharePoint PowerShell Command Line: Set-SPSite -Identity "<SiteCollection>" -LockState Unlock
More Info here: http://technet.microsoft.com/en-us/library/cc263238.aspx 

SharePoint 2010 UIVersion

After a upgrading SharePoint 2007 to 2010, the UI Version is still set to version 3, which makes it look like SharePoint 2007. In order to update the UI to look and feel like SharePoint 2010 to need to run the following script, which will update all site collections. You should save this as UpdateSPUIVersion.ps1, then run it in PowerShell.

Add-PSSnapin Microsoft.SharePoint.Powershell –ErrorAction SilentlyContinue
$SiteCollection=Get-SPSite("http://<SharePointSiteURL>")
foreach($web in $SiteCollection.AllWebs)
{ 
    $web.UIVersion = 4; 
    $web.UIVersionConfigurationEnabled = $false; 
    $web.update();
}

 

SharePoint 2010: JavaScript in Quick Launch and Top Link Bar!

The quick way to get a Quick Launch to open in a new windows is like this! The Gotcha is NOT to use double quotes! Always use single quotes.

javascript:window.open('http://www.bbc.co.uk','_blank');history.go(0);
Good link here too: http://techtrainingnotes.blogspot.ca/2010/10/sharepoint-javascript-in-quick-launch.html

To Open a SharePoint 2010 window as a Dialog such as NewForm.aspx, use this method.

EXAMPLE CODE:
JavaScript:var options=SP.UI.$create_DialogOptions();
options.url='http://techtrainingnotes.blogspot.com';
options.height = 400;
void(SP.UI.ModalDialog.showModalDialog(options))

Put this in one line in the Quick Launch, like this;

JavaScript:var options=SP.UI.$create_DialogOptions();options.url='/intranet/Lists/Issues/NewForm.aspx';void(SP.UI.ModalDialog.showModalDialog(options))


as explained here: http://techtrainingnotes.blogspot.ca/2010/12/sharepoint-opening-2010-dialog-box-from.html