Friday, June 13, 2014

Find single user permission across differerent SharePoint scopes

PowerShell script which scans these areas to to retrieve a specific user's access rights:
·         Farm Administrator's Group
·         Central Administration Web Application Policies
·         Site Collection Administrators
·         Scans the all Site collections and Sub-sites with Unique Permissions
·         Scans all Lists and Libraries with unique permissions
·         Scans all Groups which has permissions on sites and Lists
After executing the script, it generates a CSV file (Tab Separated, In fact!) with details: URL, Site/List, Title, Permission Type, Permissions as in the below screenshot. 

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Function GetUserAccessReport($WebAppURL, $SearchUser)
{
 #Get All Site Collections of the WebApp
 $SiteCollections = Get-SPSite -WebApplication $WebAppURL -Limit All

#Write CSV- TAB Separated File) Header
"URL `t Site/List `t Title `t PermissionType `t Permissions" | out-file UserAccessReport.csv

  #Check Whether the Search Users is a Farm Administrator
  $AdminWebApp= Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication}
    $AdminSite = Get-SPweb($AdminWebApp.Url)
   $AdminGroupName = $AdminSite.AssociatedOwnerGroup
    $FarmAdminGroup = $AdminSite.SiteGroups[$AdminGroupName]

     foreach ($user in $FarmAdminGroup.users)
      {
       if($user.LoginName -eq $SearchUser)
    {
     "$($AdminWebApp.URL) `t Farm `t $($AdminSite.Title)`t Farm Administrator `t Farm Administrator" | Out-File UserAccessReport.csv -Append
    }    
      }

 #Check Web Application Policies
 $WebApp= Get-SPWebApplication $WebAppURL

 foreach ($Policy in $WebApp.Policies)
   {
   #Check if the search users is member of the group
  if($Policy.UserName -eq $SearchUser)
     {
    #Write-Host $Policy.UserName
     $PolicyRoles=@()
     foreach($Role in $Policy.PolicyRoleBindings)
    {
     $PolicyRoles+= $Role.Name +";"
    }
    #Write-Host "Permissions: " $PolicyRoles

    "$($AdminWebApp.URL) `t Web Application `t $($AdminSite.Title)`t  Web Application Policy `t $($PolicyRoles)" | Out-File UserAccessReport.csv -Append
   }
   }

  #Loop through all site collections
   foreach($Site in $SiteCollections)
    {
   #Check Whether the Search User is a Site Collection Administrator
   foreach($SiteCollAdmin in $Site.RootWeb.SiteAdministrators)
       {
    if($SiteCollAdmin.LoginName -eq $SearchUser)
   {
    "$($Site.RootWeb.Url) `t Site `t $($Site.RootWeb.Title)`t Site Collection Administrator `t Site Collection Administrator" | Out-File UserAccessReport.csv -Append
   }    
  }

    #Loop throuh all Sub Sites
       foreach($Web in $Site.AllWebs)
       {
   if($Web.HasUniqueRoleAssignments -eq $True)
             {
          #Get all the users granted permissions to the list
             foreach($WebRoleAssignment in $Web.RoleAssignments )
                 {
                   #Is it a User Account?
      if($WebRoleAssignment.Member.userlogin)  
       {
          #Is the current user is the user we search for?
          if($WebRoleAssignment.Member.LoginName -eq $SearchUser)
         {
          #Write-Host  $SearchUser has direct permissions to site $Web.Url
          #Get the Permissions assigned to user
           $WebUserPermissions=@()
             foreach ($RoleDefinition  in $WebRoleAssignment.RoleDefinitionBindings)
             {
                             $WebUserPermissions += $RoleDefinition.Name +";"
                            }
          #write-host "with these permissions: " $WebUserPermissions
          #Send the Data to Log file
          "$($Web.Url) `t Site `t $($Web.Title)`t Direct Permission `t $($WebUserPermissions)" | Out-File UserAccessReport.csv -Append
         }
       }
     #Its a SharePoint Group, So search inside the group and check if the user is member of that group
     else
      {
                        foreach($user in $WebRoleAssignment.member.users)
                            {
           #Check if the search users is member of the group
         if($user.LoginName -eq $SearchUser)
          {
           #Write-Host  "$SearchUser is Member of " $WebRoleAssignment.Member.Name "Group"
            #Get the Group's Permissions on site
         $WebGroupPermissions=@()
            foreach ($RoleDefinition  in $WebRoleAssignment.RoleDefinitionBindings)
            {
                           $WebGroupPermissions += $RoleDefinition.Name +";"
                           }
         #write-host "Group has these permissions: " $WebGroupPermissions

         #Send the Data to Log file
         "$($Web.Url) `t Site `t $($Web.Title)`t Member of $($WebRoleAssignment.Member.Name) Group `t $($WebGroupPermissions)" | Out-File UserAccessReport.csv -Append
        }
       }
      }
                    }
    }

    #********  Check Lists with Unique Permissions ********/
              foreach($List in $Web.lists)
              {
                  if($List.HasUniqueRoleAssignments -eq $True -and ($List.Hidden -eq $false))
                  {
                     #Get all the users granted permissions to the list
                foreach($ListRoleAssignment in $List.RoleAssignments )
                    {
                      #Is it a User Account?
         if($ListRoleAssignment.Member.userlogin)  
          {
             #Is the current user is the user we search for?
             if($ListRoleAssignment.Member.LoginName -eq $SearchUser)
            {
             #Write-Host  $SearchUser has direct permissions to List ($List.ParentWeb.Url)/($List.RootFolder.Url)
             #Get the Permissions assigned to user
              $ListUserPermissions=@()
                foreach ($RoleDefinition  in $ListRoleAssignment.RoleDefinitionBindings)
                {
                                $ListUserPermissions += $RoleDefinition.Name +";"
                               }
             #write-host "with these permissions: " $ListUserPermissions

             #Send the Data to Log file
             "$($List.ParentWeb.Url)/$($List.RootFolder.Url) `t List `t $($List.Title)`t Direct Permissions `t $($ListUserPermissions)" | Out-File UserAccessReport.csv -Append
            }
          }
          #Its a SharePoint Group, So search inside the group and check if the user is member of that group
         else
          {
                             foreach($user in $ListRoleAssignment.member.users)
                                 {
              if($user.LoginName -eq $SearchUser)
               {
                #Write-Host  "$SearchUser is Member of " $ListRoleAssignment.Member.Name "Group"
                 #Get the Group's Permissions on site
              $ListGroupPermissions=@()
                 foreach ($RoleDefinition  in $ListRoleAssignment.RoleDefinitionBindings)
                 {
                                $ListGroupPermissions += $RoleDefinition.Name +";"
                                }
              #write-host "Group has these permissions: " $ListGroupPermissions

              #Send the Data to Log file
              "$($Web.Url) `t Site `t $($List.Title)`t Member of $($ListRoleAssignment.Member.Name) Group `t $($ListGroupPermissions)" | Out-File UserAccessReport.csv -Append
             }
            }
         }
                       }
                }
              }
    }
   }

  }

#Call the function to Check User Access
GetUserAccessReport "http://sharepoint.crescent.com" "Global\Salaudeen"
Read more here

Friday, April 25, 2014

List All Checked Out Items in SharePoint

PowerShell scripts to list out all check-out file from the site and its sub site.  This will help the administrato to find you
the file details that are check-out in the system.

# enter your site URL $spWeb = Get-SPWeb http://kmtechsys/   function GetCheckedItems($spWeb) { Write-Host "Scanning Site: $($spWeb.Url)" foreach ($list in ($spWeb.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) { Write-Host "Scanning List: $($list.RootFolder.ServerRelativeUrl)" foreach ($item in $list.CheckedOutFiles) { if (!$item.Url.EndsWith(".aspx")) { continue } $writeTable = @{ "URL"=$spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)"); "Checked Out By"=$item.CheckedOutBy; "Author"=$item.File.CheckedOutByUser.Name; "Checked Out Since"=$item.CheckedOutDate.ToString(); "File Size (KB)"=$item.File.Length/1000; "Email"=$item.File.CheckedOutByUser.Email; } New-Object PSObject -Property $writeTable } foreach ($item in $list.Items) { if ($item.File.CheckOutStatus -ne "None") { if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue } $writeTable = @{ "URL"=$spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)"); "Checked Out By"=$item.File.CheckedOutByUser.LoginName; "Author"=$item.File.CheckedOutByUser.Name; "Checked Out Since"=$item.File.CheckedOutDate.ToString(); "File Size (KB)"=$item.File.Length/1000; "Email"=$item.File.CheckedOutByUser.Email; } New-Object PSObject -Property $writeTable } } } foreach($subWeb in $spWeb.Webs) { GetCheckedItems($subWeb) } $spWeb.Dispose() }   #GetCheckedItems($spWeb) | Out-GridView   # alternative output file GetCheckedItems($spWeb) | Out-File c:\CheckedOutItems.txt -width 300

referred from  this link

Wednesday, April 23, 2014

Access SharePoint document or List item attachment from public site

Make the SharePoint document available to anonymous user without enabling anonymous access at web application level or site collection level.  If we enable anonymous access at top level then the content security will be lost.  But without enabling anonymous at top level we can make a document from document library or a list attachment to the public users using SharePoint list property.

SharePoint list has a property “AllowEveryoneViewItems”, which helps to make the document/list item attachment available to the public users.  This is the Boolean property. By setting this property to “TRUE” we can allow public user to access the document. But the public should access the direct document or list item attachment url because the public users will be able to navigate though SharePoint objects like document library or custom list.
Once the “AllowEveryoneViewItems” property set to “TRUE” then we can user the document url in any place over web for public access.

The property can be set in different ways using back end scripts or code but not through SharePoint UI.

1. Using Server Object Model
using (SPSite site = new SPSite("[site collection url]"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = rootWeb.Lists.TryGetList("[list title]");
if (list != null)
{
if (!list.AllowEveryoneViewItems)
{
list.AllowEveryoneViewItems = true;
list.Update();
}}}}

2. Using PowerShell Script

$web = Get-SPWeb -Identity "[site url]"
$list = $web.Lists.TryGetList("[list title]");
$list.AllowEveryoneViewItems = $true
$list.Update()

3. Using List Definition XML

Name="[list name]"
DisplayName="[list display name]"
Description="[list description]"
Type="10000"
BaseType="0"
Default="True"
VersioningEnabled="TRUE"
Hidden="FALSE"
AllowEveryoneViewItems="TRUE"
HiddenList="FALSE" />


It is important to note here that this property does not apply to all list items, but only to documents in document libraries or to attachments in list items. So you have to access this file directly for it to work ! (reference: SPList.AllowEveryoneViewItems property)

Here is the code snippet for accessing the file directly using HttpWebRequest

var fileContent = String.Empty;
//construct path to the navigation file
string fileUrl = "[full url of the file]";
//create webrequest to fetch this file!
var httpRequest = (HttpWebRequest)WebRequest.Create(fileUrl);
using (var webResponse = (HttpWebResponse)httpRequest.GetResponse())
{
if (webResponse.StatusCode == HttpStatusCode.OK)
{
using (var responseStream = new StreamReader(webResponse.GetResponseStream()))
{
//if we get the response, read the content from file as string
fileContent = responseStream.ReadToEnd();
}
}

}

Tuesday, April 15, 2014

Discontinued features and modified functionality in SharePoint 2013



Change Description

Change Reason

Workaround

Applies To

When you create a site, the Document Workspace site template is not available.

This scenario of collaborating on a document is already covered by the Team Site template.

The Document Workspace site template is no longer available as a site option.

SP2013 Foundation
SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

When you create a site, all Meeting Workspace site templates (Basic Meeting Workspace, Blank Meeting Workspace, Decision Meeting Workspace, Social Meeting Workspace, and Multipage Meeting Workspace) are not available.

Other collaboration features exist in SharePoint 2013 and Office 2013: Lync to conduct live meetings, OneNote to take notes during meetings, and SharePoint team site or My Site to store shared meeting notes.

All Meeting Workspace site templates are no longer available as a site option.

SP2013 Foundation
SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

The Organization Profiles feature is deprecated in SharePoint Server 2013. Organization Profiles contain detailed information about an organization such as teams, divisions, and other information that describes the organization’s hierarchy.

SharePoint features related to identities continue to evolve around the core concepts of users and groups, and SharePoint will not be investing further in OrgID.

Existing solutions based on Organization Profiles will continue to operate in SharePoint 2013. The Organization Profiles feature will be removed completely from the next major release of SharePoint, and solutions created by using Organization Profiles will not be supported.

SP2013 Foundation
SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Insert Barcode command is no longer available on the ribbon. The functionality of requiring SharePoint generated barcodes to be embedded in a Microsoft Word document has been discontinued.

Feature does not meet expectations and with minimal user adoption.

Write a custom Open XML application that takes the server side barcode and injects into the Word document.

SP2013 Server

SP2013 Online

The ability to generate and embed a label containing metadata about a Word, Excel or PowerPoint document is no longer available. Settings for this feature have been removed.

Feature does not meet compliance and records management user expectations.

N/A

SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Broadcast will no longer be supported by SharePoint servers.

Hosting and broadcasting PowerPoint presentations can be done more effectively using other applications such as Microsoft Lync 2013.

Use Microsoft Lync 2013. Also, PowerPoint will continue to support broadcast against the Office Broadcast Service (a public offering) or via Lync.


SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Slide libraries are no longer available.

Design limitation in SharePoint Server 2013.

Users are still able to insert slides from PowerPoint files


SP2013 Server

SP2013 Online
Office Web Apps Server 2013




Change Description

Change Reason

Workaround

Applies To

The SharePoint Web Analytics system will no longer be available or upgradable to SharePoint 2013. Previous analytics will not be imported into new version.

Less than optimal performance running service at scale in large enterprises.

A new analytics system that is part of the Search feature replaces the discontinued service.


SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Workbooks with external data connections that use delegated Windows authentication cannot be refreshed in the browser when Office Web Apps Server is used to display workbooks in a browser window. Workbooks that have credentials stored either in the Secure Store or in the connection string can still be refreshed in the browser in Office Web Apps Server.

Design limitation in Office Web Apps Server 2013.

You can still open these workbooks in the desktop Excel client program to refresh them. Additionally, an administrator can configure Excel Services in SharePoint Server to display workbooks instead of Office Web Apps Server 2013.


SP2013 Server

Office Web Apps Server 2013




Change Description

Change Reason

Workaround

Applies To

The ability to get an RSS feed of your search results in SharePoint is no longer available.

Better experience using Search alerts and SharePoint RSS feeds.

Search alerts and SharePoint RSS

SP2013 Foundation
SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Help content added via the Custom Site Collection Help feature or HCINSTAL.EXE will no longer display in SharePoint Online.

Wikis provide a more flexible platform for the delivery of custom help content.

Help content can still be provided via wikis or other sites that you manage.

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

The Group Work site template is no longer available as a site option and the Group Work Lists feature is no longer available as a site feature.

Similar features can be used with the Team site template.

The Group Work site template is no longer available as a site option.

SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

The Personalization site template is no longer available as a site option.

Similar features can be used with the Team site template.

The Personalization site template is no longer available as a site option.

SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Users will no longer be able to generate Microsoft Visio Pivot Diagrams directly from a SharePoint Task list.

The Assigned to field in the Task list is now a multi-valued field which is not supported by Visio.

N/A

SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

The Visual Upgrade feature is no longer available but is being replaced by a site collection upgrade feature.

The new deferred site collection upgrade preserves the user experience of the O14 version with significantly higher fidelity than visual upgrade could, including the preservation of UI and SPFeature customizations.

The Visual Upgrade feature is no longer available but is being replaced by a site collection upgrade feature.

SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

The Chart Web Part is no longer available.

Similar features can be used with other applications, such as Excel Services.

If you used the Chart Web Part in SharePoint Server 2010, you can continue to use it in SharePoint Server 2013. If you did not use the Chart Web Part in SharePoint Server 2010, you can use other SharePoint functionality such as Excel Services to display a chart in a SharePoint site.

SP2013 Server

SP2013 Online

SharePoint Status Indicators and Status Lists are no longer available.

Similar features can be used with other applications, such as Excel Services.

If you used SharePoint Status Indicators in SharePoint Server 2010, you can continue to use them in SharePoint Server 2013. If you did not use SharePoint Status Indicators and Status Lists in SharePoint Server 2010 you can use other SharePoint functionality such as Excel Services to create key performance indicators (KPIs).

SP2013 Server

SP2013 Online