Tuesday, September 2, 2014

Configure People Picker Settings in SharePoint 2013

The Problem isIf a web application is using Windows authentication and the site user directory path is not set, the People Picker control searches all the Active Directory to resolve users' names or find users, instead of searching only users in a particular organizational unit (OU).” Microsoft TechNet site said.

Below is the PowerShell and stsadm commands to Retrieve Users from a Specific OU in Active Directory:

Get current user account directory path for all Site Collections in a Web Application:
Get-SPSite -Limit All | Select Url, UserAccountDirectoryPath 

Get current service account directory path:
stsadm -o getproperty -url http://ServerName -pn peoplepicker-serviceaccountdirectorypaths 

Set service account directory path:
stsadm -o setproperty -url http://contosto -pn "peoplepicker-serviceaccountdirectorypaths" -pv "OU=Contoso-Admin,DC=Contoso,DC=com" 

Configure settings for Web Application (All Site Collections in  a Web Application):
$WebApp = "http://WebApp"
Get-SPWebApplication $WebApp | Get-SPSite -Limit All |ForEach-Object { Set-SPSite -Identity $_.Url -UserAccountDirectoryPath "OU=Contoso-Users,DC=Contoso,DC=com" }

Configure settings for a Site Collection:
Set-SPSite -Identity "http://Contoso/SiteCollection" -UserAccountDirectoryPath "OU=Contoso-Users,DC=Contoso,DC=com"

Monday, June 9, 2014

Configuring OneDrive for Business Use in SharePoint 2013


       1- Blocking File Types:
a. Central Administration > Manage Web Applications > The MySite Web Application > “Blocked File Types” from the ribbon.
b. Add the extension you want in a new line.

              2- Quota Limit Per User:
a. Create Personal Quota template.
b. Change Quota template for the Site Collection of the user
Central Admin > Application Management > Site Collections > Configure quotas and locks, or if you have large number of sites then use this PowerShell;

$SPWebApp = Get-SPWebApplication http://MySite

foreach ($SPSite in $SPWebApp.Sites)
{
    if ($SPSite -ne $null)
    {
        Set-SPSite -Identity $SPSite.url -QuotaTemplate "Quota Template Name"
        $SPSite.Dispose()
    }
}

             3- Set max upload size:
a. Central Admin > Manage Web Applications > The MySite Web Application > “General Settings” from the ribbon.
b. In the “Maximum upload size”, add the size.

Wednesday, June 4, 2014

Get SharePoint 2013 Site Collection Size Using PowerShell

I was trying to get the usage size for one of the SharePoint personal sites, and I ended up with this script.
The script is for getting all site collections usage compared to its maximum size, sorted by size of the Site Collections and the output to a HTML file.

$a = "<style>"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 1px;border-style: solid;border-color: black;}"
$a = $a + "TD{border-width: 1px;padding: 1px;border-style: solid;border-color: black;}"
$a = $a + "</style>"

Get-SPSite -Limit All | select url, @{label="Size in MB";Expression={$_.usage.storage/1MB}},@{label="Capacity";Expression={$_.Quota.StorageMaximumLevel/1MB}} | Sort-Object -Descending -Property "Size in MB" | ConvertTo-Html -Head $a -title "Site Collections sorted by size" | Set-Content sc.html


Cheers,

Sunday, May 25, 2014

Hide SharePoint Calculated Columns


Note that you can't hide the SharePoint calculated columns by the normal way, you have to use PowerShell to do that !

$web = get-spweb http://SPWeb/Site/subsite $list = $web.Lists["list name"]
$field = $list.Fields["Column Name"] $field.ShowInDisplayForm = $false $field.ShowInEditForm = $false $field.ShowInListSettings = $false$field.ShowInVersionHistory = $false$field.ShowInViewForms = $false $field.ShowInNewForm = $false
$field.Update($true) $web.Site.Dispose()

Thursday, May 8, 2014

Access denied error while editing SharePoint 2013 List item.

While editing an item in a SharePoint 2013 List, I faced this error: "Access denied. You do not have permission to perform this action or access this resource" although the user has already an edit permission!!! 

I checked the ULS logs and the exception was "Original error: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"

After alot of searching, the solution was so simple, go to List settings > Advanced settings, and in the "Item-level Permissions" field, change "Create and Edit access:   Specify which items users are allowed to create and edit" to "  " ... then save



So Simple ... huh ?!