Friday, 21 October 2016

Get All sites info using PowerShell

## SharePoint DLL  
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")  
  
$webApplicationURL = Read-Host "Enter Web application"  
$webApp = Get-SPWebApplication $webApplicationURL

  
if($webApp -ne $null)  
$WebName=$webApp.Name
$FileName="D:\SharePointTeam\GetAllSites\"+$WebName+".csv"
Write-Host $FileName

#Write-Host "Web Application : " + $webApp.Name  
foreach($siteColl in $webApp.Sites)  
{  
if($siteColl -ne $null)  
{  
Write-Host -foregroundcolor red "Site Collection: "$siteColl.Url  
Get-SPSite $siteColl | Get-SPWeb -Limit All | Select Title, Url
$SiteName=Get-SPSite $siteColl | Get-SPWeb -Limit All | Select Title, Url 
$Sitename | Out-File -Append $FileName -width 500
}  
else  
{  
Echo $siteColl "does not exist"  
}  
}  
}  
else  
{  
Write-Host  $webApplicationURL "does not exist, check the WebApplication name"  
}​


Get info about lists and libraries in site using PowerShell

The script will produce the following output:

1.    Total # of Document Libraries
2.     Total # of Document Libraries
2.    Total # of items in all Document Libraries
3.    Total # of items in DocLib\Subfolders
4.     Start Time and End Time of Script



Instructions for running the script:  
 
1.    Copy the below script and save it in notepad
2.    Save it with a anyfilename.ps1 extension
3.    To run, copy the file to a SharePoint Server
4.    Select Start\Microsoft SharePoint 2010 Products\SharePoint 2010 Management Shell
5.    Browse to directory holding the copied script file
6.    Run the script:  .\anyfilename.ps1 (assuming anyfilename is the name of the file)

Script is below:

[Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
Start-SPAssignment -Global

$starttime = Get-Date
#Creating new site object
$siteurl = Read-Host "Enter the name of your site and press enter"
$site = New-Object Microsoft.SharePoint.SPSite($siteurl)

#Assigning all webs (sites) to $webs
$webs = $site.Allwebs

####################################################
#System Libraries defined so they won’t be touched##
####################################################

$systemlibs =@("Converted Forms", "Customized Reports", "Documents", "Form Templates",
                              "Images", "List Template Gallery", "Master Page Gallery", "Pages",
                               "Reporting Templates", "Site Assets", "Site Collection Documents",
                               "Site Collection Images", "Site Pages", "Solution Gallery",
                               "Style Library", "Theme Gallery", "Web Part Gallery", "wfpub")

Write-Host  "Total number of webs that will be traversed: " $webs.count

$DocLibsCount = 0
$DocLibwItems = 0
$totalitems = 0
$subfolderitems = 0

foreach($web in $webs)
    {
        $listcoll = $web.lists
       
        foreach($list in $listcoll)
        {
             if($list -eq $null)
             {
                Write-Host
             }
             else
             {
                $base = $list.GetType()
                if($base.name -eq "SPDocumentLibrary")
                {
                    if ($systemlibs -contains $list)
                    { continue}
                    else
                        {
                          $DocLibsCount += 1  
                          $items = $list.items
                         
                          if($items -ne "0")
                          {
                           $DocLibwItems += 1
                           Write-Host "Processing ItemCount for DobLib " $DocLibsCount -ForegroundColor Red
                           $totalitems  += $items.count
                 
                           $name = $list.Title
                           $folders  = $web.GetFolder($name).SubFolders
                           for($etr = 0;$etr -lt $folders.count; $etr++)
                            {
                             if($folders[$etr].Name -ne "Forms")
                               {
                                 Write-Host "Processing SubFolder ItemCount" -ForegroundColor Red
                                 $tempcount = $folders[$etr].ItemCount
                                 $subfolderitems += $tempcount
                                 }
                            }
                           }
                          }
                   }
                 }
              }
          }
 
Write-Host
Write-Host
Write-Host "Total # of Document Libraries: " $DocLibsCount -ForegroundColor Green
Write-Host "Total # of Document Libraries that contain items: " $DocLibwItems -ForegroundColor Green
Write-Host "Total # of items: " $totalitems -ForegroundColor Green
Write-Host "Total # of items in DocLib\Subfolders: " $subfolderitems -ForegroundColor Green
$finishtime = Get-Date
Write-Host
Write-Host “Script Duration” –ForegroundColor Yellow
Write-Host “Started:   “ $starttime –ForegroundColor Yellow
Write-Host “Finished: “ $finishtime –ForegroundColor Yellow

Stop-SPAssignment -Global

Migrating sites from one location to another location using PowerShell

[Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

# add SharePoint snapin
Add-PSSnapin Microsoft.SharePoint.PowerShell –ea SilentlyContinue

Start-SPAssignment -Global

$starttime = Get-Date

#Creating new site object
$siteurl = Read-Host "Enter the name of your site and press enter"
$site = New-Object Microsoft.SharePoint.SPSite($siteurl)

#Assigning all webs (sites) to $webs
$webs = $site.Allwebs

$systemlibs =@("Converted Forms", "Customized Reports", "Documents", "Form Templates",
                              "Images", "List Template Gallery", "Master Page Gallery", "Pages",
                               "Reporting Templates", "Site Assets", "Site Collection Documents",
                               "Site Collection Images", "Site Pages", "Solution Gallery",
                               "Style Library", "Theme Gallery", "Web Part Gallery", "wfpub")

Write-Host  "Total number of webs that will be traversed: " $webs.count

$DocLibsCount = 0
$DocLibwItems = 0
$totalitems = 0
$subfolderitems = 0

foreach($web in $webs)
    {
        $listcoll = $web.lists
     
        foreach($list in $listcoll)
        {
             if($list -eq $null)
             {
                Write-Host
             }
             else
             {
                $base = $list.GetType()
                if($base.name -eq "SPDocumentLibrary")
                {
                    if ($systemlibs -contains $list)
                    { continue}
                    else
                        {
                          $DocLibsCount += 1  
                          $items = $list.items
                       
                          if($items -ne "0")
                          {
                           $DocLibwItems += 1
                           Write-Host "Processing ItemCount for DobLib " $DocLibsCount -ForegroundColor Red
                           $totalitems  += $items.count
                 
                           $name = $list.Title
                           $folders  = $web.GetFolder($name).SubFolders
                           for($etr = 0;$etr -lt $folders.count; $etr++)
                            {
                             if($folders[$etr].Name -ne "Forms")
                               {
                                 Write-Host "Processing SubFolder ItemCount" -ForegroundColor Red
                                 $tempcount = $folders[$etr].ItemCount
                                 $subfolderitems += $tempcount
                                 }
                            }
                           }
                          }
                   }
                 }
              }
          }

Write-Host
Write-Host
Write-Host "Total # of Document Libraries: " $DocLibsCount -ForegroundColor Green
Write-Host "Total # of Document Libraries that contain items: " $DocLibwItems -ForegroundColor Green
Write-Host "Total # of items: " $totalitems -ForegroundColor Green
Write-Host "Total # of items in DocLib\Subfolders: " $subfolderitems -ForegroundColor Green
$finishtime = Get-Date
Write-Host
Write-Host “Script Duration” –ForegroundColor Yellow
Write-Host “Started:   “ $starttime –ForegroundColor Yellow
Write-Host “Finished: “ $finishtime –ForegroundColor Yellow

#create export folder

$exportfolder = "C:\Site exports"
$exportfile = "\site_export.cmp"
$exportsite = "http://Sourcesite/abc"
$exportlocation = $exportfolder+$exportfile
$importlocation = "http://destination/abc"

$null = New-Item $exportfolder -type directory
#export site
Export-SPWeb $exportsite –Path $exportlocation -IncludeUserSecurity -IncludeVersions All
Write-host "$exportsite has been exported to $exportlocation"
#create new site ready for import
Write-host "$importlocation created ready for import"
#import site
Import-SPWeb $importlocation –Path $exportlocation -IncludeUserSecurity –UpdateVersions Overwrite
Write-host "$exportsite has been imported to $importlocation" -foregroundcolor "Green"


#Creating new site object
$starttime = Get-Date

$siteurl = Read-Host "Enter the name of your site and press enter"
$site = New-Object Microsoft.SharePoint.SPSite($siteurl)

#Assigning all webs (sites) to $webs
$webs = $site.Allwebs

$systemlibs =@("Converted Forms", "Customized Reports", "Documents", "Form Templates",
                              "Images", "List Template Gallery", "Master Page Gallery", "Pages",
                               "Reporting Templates", "Site Assets", "Site Collection Documents",
                               "Site Collection Images", "Site Pages", "Solution Gallery",
                               "Style Library", "Theme Gallery", "Web Part Gallery", "wfpub")

Write-Host  "Total number of webs that will be traversed: " $webs.count

$DocLibsCount = 0
$DocLibwItems = 0
$totalitems = 0
$subfolderitems = 0

foreach($web in $webs)
    {
        $listcoll = $web.lists
     
        foreach($list in $listcoll)
        {
             if($list -eq $null)
             {
                Write-Host
             }
             else
             {
                $base = $list.GetType()
                if($base.name -eq "SPDocumentLibrary")
                {
                    if ($systemlibs -contains $list)
                    { continue}
                    else
                        {
                          $DocLibsCount += 1  
                          $items = $list.items
                       
                          if($items -ne "0")
                          {
                           $DocLibwItems += 1
                           Write-Host "Processing ItemCount for DobLib " $DocLibsCount -ForegroundColor Red
                           $totalitems  += $items.count
                 
                           $name = $list.Title
                           $folders  = $web.GetFolder($name).SubFolders
                           for($etr = 0;$etr -lt $folders.count; $etr++)
                            {
                             if($folders[$etr].Name -ne "Forms")
                               {
                                 Write-Host "Processing SubFolder ItemCount" -ForegroundColor Red
                                 $tempcount = $folders[$etr].ItemCount
                                 $subfolderitems += $tempcount
                                 }
                            }
                           }
                          }
                   }
                 }
              }
          }

Write-Host
Write-Host
Write-Host "Total # of Document Libraries: " $DocLibsCount -ForegroundColor Green
Write-Host "Total # of Document Libraries that contain items: " $DocLibwItems -ForegroundColor Green
Write-Host "Total # of items: " $totalitems -ForegroundColor Green
Write-Host "Total # of items in DocLib\Subfolders: " $subfolderitems -ForegroundColor Green
$finishtime = Get-Date
Write-Host
Write-Host “Script Duration” –ForegroundColor Yellow
Write-Host “Started:   “ $starttime –ForegroundColor Yellow
Write-Host “Finished: “ $finishtime –ForegroundColor Yellow

Stop-SPAssignment -Global

SharePoint 2010 Event ID 6482

Resolution steps:

Below is the step by step provided by Microsoft in this KB Article for doing this:
1.     Stop the Windows SharePoint Services Timer service (Found in Windows Services)
2.     Navigate to the cache folder
In Windows Server 2008, the configuration cache is in the following location:
Drive:\ProgramData\Microsoft\SharePoint\Config
In Windows Server 2003, the configuration cache is in the following location:
Drive:\Documents and Settings\All Users\Application Data\Microsoft\SharePoint\Config
Locate the folder that has the file "Cache.ini"
(Note: The Application Data folder may be hidden. To view the hidden folder, change the folder options as required)
3.     Back up the Cache.ini file.
4.     Delete all the XML configuration files in the GUID folder. Do this so that you can verify that the GUID folder is replaced by new XML configuration files when the cache is rebuilt.
5.     Note When you empty the configuration cache in the GUID folder, make sure that you do not delete the GUID folder and the Cache.ini file that is located in the GUID folder.
6.     Double-click the Cache.ini file.
7.     On the Edit menu, click Select All. On the Edit menu, click Delete. Type 1, and then click Save on the File menu. On the File menu, click Exit.
8.     Start the Windows SharePoint Services Timer service
9.     Note The file system cache is re-created after you perform this procedure. Make sure that you perform this procedure on all servers in the server farm.
10. Make sure that the Cache.ini file in the GUID folder now contains its previous value. For example, make sure that the value of the Cache.ini file is not 1.


Moving SharePoint 2010 Designer Workflows between Sites



You would be faced by the need to move workflows you developed using SharePoint designer from one site to another. This might be the case if for example you developed and tested the workflow on a testing environment and now wants to move to the production environment without the need to re-develop the workflow.
The steps to perform this is rather simple:
  1. Export the workflow to Visio.
  2. Edit the VWI archive and delete the configuration file.
  3. Import the workflow back to your destination site.
So open the SharePoint designer and open the source site. click on the workflows link on the left and then the workflow you want to move. Click on the ribbon on export to Visio button.
image
Now rename the file exported (VWI file) to be a ZIP file and open it with Windows Explorer. You will find a file named “workflow.xoml.wfconfig.xml”
image
Just delete this file. Now rename the archive back to be a VWI file.
Now open the destination site and click the import from Visio and browse to the edited VWI file. This will allow you to re-associate your workflow as if it was created or exported from Visio rather than the designer while preserving any development made in the workflow it self.

Excel Workbook error Message


Error Message:
To open this workbook, your computer must have a version of Microsoft Excel installed and your Web browser must support opening files directly from Excel in the browser.

Very important note: before starting any troubleshooting on this, make sure that your IE version should not be 64-bit.

Why?- Internet Explorer x64 is currently not an optimal approach since many Microsoft- and thirst-party ActiveX objects still do not support 64 bits. Office 2007/2010 does not ship 64-Bit controls for SharePoint integration, such as single document upload or multiple document upload, or "Connect to Outlook", "Open in Explorer View" and many more. Considering these limitations you may want to use the 32 bit version of Internet Explorer for the future to take benefit of the SharePoint integration features.

The required component / add-ons are simply missing for IE x64 and therefore causing several features not to function, being greyed-out or generate an [error] message once requested, such as "Message from webpage: The document could not be opened for editing"

Resolution:
Repair is a great Office tool that I have used in many previous versions of Office to fix things like the Normal.dot template being changed in Word, Outlook PST and email problems, etc. If Office 2013 is running slow or having some other issue, try performing a repair and hopefully it will fix your problem. Enjoy!

Here I will share the repair process for 3 different office versions i.e. Office 2010, Office 2013 and Office 2007.

If you are using Office 2010 then please try to repair by following steps:

1.   Click on Start and then Control Panel.
2.   After the Control Panel window opens, click on Uninstall a Program.
3.   A list of all installed programs should now appear. Highlight Microsoft Office 2010, and click on Change.
4.   After the dialog box loads, choose the Repair option and click Continue.
5.   This process may take a few minutes, but after completion, you will be prompted to exit and restart any open Office programs. You may then click Close.
6.   You may be prompted to reboot your computer to apply all changes and complete setup.

If you are using Office 2013 then please try to repair by following steps:
1.   To repair Office 2013, you first have to open the Control Panel and then click on Programs and Features.
2.   Click on Office 2013 and then click on the Change button.
3.   Next, click on the Repair radio button and click Next. This will start the repair process.
4.   It’ll take some time to repair and once it has finished, you’ll see a message saying the configuration of Office 2013 is complete.
5.   You’ll then have to restart the computer in order for the repair to complete.

If you are using Office 2007 then please try to repair by following steps:

1.   To begin, go to the Start Menu > All Programs > Microsoft Office > Microsoft Office Tools, and then click on Microsoft Office Diagnostics.
2.   After Microsoft Office Diagnostics opens, click Continue on the first page.
3.   By default, all of the diagnostic tests are enabled, so you may click on Run Diagnostics to proceed with diagnosis and repair.
4.   After running the diagnostics, a results page will be displayed.
5.   After clicking continue, your web browser will load with Microsoft's recommendations for the next steps to resolve any discovered issues with Microsoft Office.​

Creating & Managing Alerts SP2010

SharePoint 2010 - Managing Alerts

This article explains how to manage alerts within a SharePoint site.
Alerts are notifications of changes to content on a site that you receive as email messages. You can use either the User Information page or the Manage Alerts on this Site page to view and cancel your alerts and change the settings for your alerts. If you have permission to manage a site, you can also view and cancel alerts for other people by using the User Alerts page.
This article focuses on how to manage alerts for yourself and for other people if you are a site administrator.

VIEW MY ALERTS ON A SITE

1.    At the top of the site, click your name, and then click My Settings.
2.    On the User Information page, click My Alerts.

CHANGE MY ALERT SETTINGS

1.    At the top of the site, click your name, and then click My Settings.
2.    On the User Information page, click My Alerts.
3.    Click the name of the alert that you want to change.
4.    On the Edit Alert page, change the settings that you want to change.
5.    Click OK.
Tip: When you receive an email alert, you can click a link to see alert information on the site.

CANCEL AN ALERT FOR MYSELF

1.    At the top of the site, click your name, and then click My Settings.
2.    On the User Information page, click My Alerts.
3.    Select the check box next to the alert that you want to cancel.
4.    Click Delete Selected Alerts.
5.    When you are prompted to confirm the deletion, click OK.

VIEW ALERTS FOR OTHER PEOPLE ON A SITE

To view alerts for other people, you must be a site owner.
1.    Click the Site Actions menu and then click Site Settings.
2.    On the Site Settings page, under Site Administration, click User alerts.
3.    In the list next to Display alerts for, select the person whose alerts you want to view.
4.    Click the Update button.

CANCEL AN ALERT FOR ANOTHER PERSON

To cancel alerts for other people, you must be a site owner.
1.    Click Site Actions menu and then click Site Settings.
2.    On the Site Settings page, under Site Administration, click User alerts.
3.    In the list next to Display alerts for, select the person whose alerts you want to view.
4.    Click the Update button.
5.    Select the check box next to the alert that you want to cancel.
6.    Click Delete Selected Alerts.
7.    When you are prompted to confirm the deletion, click OK.

SharePoint 2010 - Creating Alerts

This article explains what alerts are and how to use them to stay informed of changes to SharePoint content.
Alerts are a great way to keep track of the changes your teammates make to documents and lists on your site. You can use alerts to receive an email notification when content is added or modified on your site. Site administrators also have the ability create alerts for other members of the site.

CREATING ALERTS

1.    Browse to the list or library where you want to subscribe to an alert.
2.    In the list or library tools ribbon, click the Alert Me button.
The New Alert window appears
3.    In the Alert Title box, enter a name for the alert.
Make the name something meaningful to you.
4.    If you are a site administrator you have the option of subscribing other site members to alerts by entering their names in the Send Alerts To box. If you do not have this permission you will not see section.
Site owners may want to subscribe multiple users to an alert to make sure they get important updates, as well as encourage them to contribute to a discussion board, blog, or wiki. Users can still opt out by modifying settings in their Alert settings.
5.    In the Change Type section, specify the types of changes to be alerted on.
6.    In the Send Alerts for These Changes section, optionally filter the alerts that are sent.
The options you see here vary based on the kind of list you're working with. For example, a task list allows you to receive an alert when a task is marked complete or anytime a high-priority task changes.
Any time users say they need a workflow to receive notification, try an alert first. You'd be surprised at how often alerts provide the options that are needed.
7.    In the When to Send Alerts section, specify when the alerts should be sent.
8.    Click OK to create the alert.