Windows PowerShell script for reading the SharePoint Secure Store

when you assign a credential in a secure store for any target application. there is no way to check which credentials you used last time.
 
Below powershell script can be used to read the credentials inside the secure store.



Powershell to update quick launch in SharePoint 2013

Below is the powershell, which is being used to

1- update the title and URL of existing heading in left navigation.
2- add all the sibling subsites (title and URL) as a node under the heading.

#SharePoint site url
$MainSiteURL = "Site URL for which you want to change the quick launch"
$ParentSiteURL = "Site URL of the parrent site of above site as you want to add the sibling subsites"
$ParentSiteName = "Name of a parent site"

           
#Get the SPWeb object for the site url           
$MainWeb = get-spweb $MainSiteURL
$ParentWeb = get-spweb $ParentSiteURL

#Get the quick launch menu           
$ql = $MainWeb.Navigation.QuickLaunch;           

#change the heading title and URL
$qlHeading = $ql | where { $_.Title -eq "subsites" }
$qlHeading.Title = $ParentSiteName
$qlHeading.Url = $ParentSiteURL
$qlHeading.Update()

# get all subsites
if($ParentWeb.Webs -ne $null)
{
    foreach($sitesUnderParentWeb in $ParentWeb.Webs)
    {
        # to create a new node
        $newnode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode($sitesUnderParentWeb.Title, $sitesUnderParentWeb.Url, $true)
        # add this node to heading
        $qlHeading.Children.AddAsLast($newnode)
       
    }
}
$MainWeb.Update()           

SharePoint Online Backup and Restore - Nice article

I got the below nice article about SharePoint Online backup and Restore by Threewill

http://www.threewill.com/the-4-options-you-need-to-know-about-sharepoint-online-backup-and-restore/ 


  1. Use the recycle bin and version history.
  2. Use a 3rd party tool for backup and restore (there are several).
  3. Manually backup sites, lists, and libraries 
  4. Create an Office 365 support request 
Few more pieces of information:
  • Site collection backups are performed every 12 hours and are kept for 14 days.
  • If you want to restore a backup, you need to create a support ticket and specify the earliest backup time, latest backup time, and optimal backup time.  Say your site collection was messed up during the day on Tuesday.  You could state the earliest backup time as close of business Monday (e.g., 6 PM), the latest backup time as open of business on Tuesday (e.g., 6 AM), and the optimal backup time as Tuesday at 4 AM.  The support team will get you the best backup based on this information.  You should have at least 12 hours between the earliest and latest times.
  • The restoration is done to a site collection.  The entire site collection will be replaced and any changes made after the backup time will be lost (must be re-done after the restore).
  • Once a restore is requested, it may take 2 or more days for the restore to be performed.  This is done based on O365 support’s triage process and the perceived priority of the request.  The tenant license or overall number of users for the tenant does not change the priority.

Check if your DNS is working properly - Online solution

Below is the URL to verify if the DNS is working correctly.

http://dnscheck.pingdom.com/

Provision Service using Powershell


Below is the command to provision or un-provision any service


Add-PSSnapin microsoft.sharepoint.powershell
Get-SPServiceInstance | Where-Object {$_.Server.Name -eq "NameofServer"} | Sort-Object TypeName | Format-Table -AutoSize
$si = Get-SPServiceInstance | Where-Object {($_.TypeName -match "NameOfServiceApplication") -and ($_.Server.Name -eq "NameOfServer")}
$si | fl
$si.Unprovision()
$si.Provision()
$si.Status
While ($si.Status -eq "Provisioning")
{
    Start-Sleep 3
    Write-Host "." -NoNewline
    $si = Get-SPServiceInstance | Where-Object {($_.TypeName -match "NameOfServiceApplication") -and ($_.Server.Name -eq "NameOfServer")}
}

Create Site collection using Powershell - Including Default groups

The below command is used to create a hosted Site collection under any web application using power-shell.



Add-PSSnapin "Microsoft.sharepoint.powershell"

$url = "Name of your Hosted Site collection"
$hostHeaderWA = "Name of your web application"
$SCollectionTitle = "Title of your site collection"
$SCollDescription = "Description of your site collection"

New-SPSite $url -HostHeaderWebApplication $hostHeaderWA `
                -Name $SCollectionTitle `
                -Description $SCollDescription `
                -OwnerAlias 'DomainName\AccountName' `
                -language 1033 `
                -Template 'STS#0'

The when you create your site collection (OR hosted site collection), you will see the default Owners/Members/Visitors groups are missing.
To create those groups, use the below Power-Shell command

$web = Get-SPWeb $url
$PrimaryLogin = $web.EnsureUser("DomainName\AccountName")
$web.CreateDefaultAssociatedGroups($PrimaryLogin,"","")

you can run the entire Power-Shell command together as well.



SQL Standard OR Enterprise Version of RS (Reporting services) for SharePoint 2013

I got a nice finding about using either a MSSQL Standard OR Enterprise version of RS for SharePoint 2013.

1- if you use the SQL Standard 2012 for RS in SharePoint 2013, you will not be able to activate the SQL Server Reporting Services on more than one application Servers of SharePoint.

2- If you use Enterprise version of SQL 2012, the SQL Server Reporting Service can be started on multiple application servers.

Here is more details about it.

http://netwovenblogs.com/2013/08/04/reporting-services-in-sharepoint-2013-integrated-mode-cannot-support-scale-out-mode/

SQL Server Reporting Services Scale-out mode is supported by following SQL Server editions: Enterprise, Business Intelligence. (Refer MSDN: Features Supported by the Editions of SQL Server 2012)
With your SQL Server 2012 Enterprise or Business Intelligence editions, under your SharePoint 2013 (2010) you could always scale out to more than one SharePoint server. (Refer MSDN Add an Additional Report Server to a Farm (SSRS Scale-out) )
While you have SQL Server 2012 Standard edition, under the SharePoint 2013 Farm, you can have only one instance of SQL Server Reporting Services in the SharePoint Integrated mode. While you try to start another instance of Reporting Service in the farm on different server within the Farm, you will receive the above message.
If you intend to start the SQL Server Reporting Services on a different server than the service is currently running, you should first stop the service on the current running service and then start on your desired server. But also be aware other installation and configuration requirements for hosting the SSRS Service on the Server before you try to start the SSRS Service on a new server

Configure Custom Access Denied Page - SP 2013

I found a really nice article for creating custom access denied page from Danish.

http://a2zdinesh.blogspot.in/2014/05/configure-custom-access-denied-page-bug.html


Danish also explained the step by step configuration (Development and deployment) for creating custom access denied page.

Running Powershell for SharePoint Online from local machine

1- download SharePoint Online Management Shell  on your local machine.

Download SharePoint Online Management Shell

2- once this is installed, you will find an icon for Powershell Online.

3- click on that icon.

4- before you execute any command for SharePoint online. run the below command

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

5- With SharePoint 2013 online you need to connect to your tenant administration site to be able to do anything.

Connect-SPOService –url  $siteCollectionUrl –Credential $O365Credential

6-Note: I was facing an error while executing the above command. i took the help from microsoft office 356 community. see the link below.

Help from office 365 community


7- Finally i got it run. after executing the step 4. i ran the below command.
$cred = [System.Net.CredentialCache]::DefaultCredentials
[System.Net.WebRequest]::DefaultWebProxy.Credentials = $cred

8- then i ran the command in step 5 and i was able to connect to SharePoint Online powershell.




PowerShell script to Take a backup of Service application in SP 2013

 
Below is the Power Shell script to Take a backup of Service application in SP 2013

 
$currentDateTime = (Get-Date -Format yyyy-MM-dd-HH-mm)
$SrvAppFolder = Test-Path "\\$env:computername\SPServiceApplicationBackup\"


#add sharepoint snapin
Add-PSSnapin microsoft.sharepoint.powershell 
    
#Backup Service Applications
#Excel Services Application
Backup-SPFarm -Directory $backupSAFolder -BackupMethod Full -Item "Farm\Shared Services\Shared Services Applications\Excel Services Application"
        
#Secure Store Service 

Backup-SPFarm -Directory $backupSAFolder -BackupMethod Full -Item "Farm\Shared Services\Shared Services Applications\Secure Store Service"
Backup-SPFarm -Directory $backupSAFolder -BackupMethod Full -Item "Farm\Shared Services\Shared Services Proxies\Secure Store Service"

Re-ghost Items presented in Master page gallery

I found a nice article about re-ghost items (specially for master pages and page layouts)

http://mosshowto.blogspot.nl/2008/10/re-ghost-master-pages-sharepoint.html

Error While Creating Web Application in SharePoint 2013

Error : While creating a new web application in SharePoint 2013 using central administration, I was getting the below error every time. "Internet Explorer cannot display the webpage".















Solution :
1- Go to IIS Manager.
2- Look for the application pool "DefaultAppPool"
3- Change the following 3 Process Model time settings
3a.Ping Maximum Response Time --> set to 400
3b.Shutdown Time Limit --> set to 400
3c.Startup Time Limit --> set to 400
4. reset the IIS. Try to create the web application once again.



Once the web application is created, you can revert the settings to 90 and finally do the IISRest Once again. I got the above information from the below post.
http://blogs.ibs.com/Duane.Odum/Lists/Posts/Post.aspx?ID=33

Find List details if you know the List IDs

if you only know the list id and want to know the other details of the list, below is the code to get that
protected void Page_Load(object sender, EventArgs e)
{
string[] _listArray = {"List ID 1", "List ID 2", "List ID 3"};
using (SPSite oSite = new SPSite("MySiteURL"))
{
SPWeb oWeb = oSite.OpenWeb();
SPListCollection allLists = oWeb.Lists;
foreach (SPList list in allLists)
{
foreach (string singleArraylist in _listArray)
{
if (list.ID.ToString().ToUpper() == singleArraylist.ToString().ToUpper())
{
Response.Write("List Name :\t" + list.Title + " List ID :" + list.ID + "");
}
}
}
}
}