Monday, November 21, 2016

we increase the maximum size of a list templates in SharePoint 2010

When we try to save document library as template we get an error If the document library is big. It will give an error like below,

'The list is too large to save as a template. The size of a template cannot exceed 52428800 bytes.'. 

By default the size limit is 50 MB in SharePoint 2010 and SharePoint 2103

We can increase the list template size by running this below stsadm command in PowerShell.

stsadm -o setproperty -propertyname max-template-document-size -propertyvalue 100000000

This is for  increasing limit to 100 MB.









Friday, November 18, 2016

The data types of the following form fields do not match the SharePoint list

When you have a custom InfoPath form applied to a SharePoint 2010 list, when you try to edit or create an item in the list.It may throw error like below,

Error Message: The data types of the following form fields do not match the SharePoint list: ListFieldName

This issue causes because of If you have tried to modify the form recently, due to missing or extra field  in your SharePoint list.

 Resolution is simple here:

 If you go into your  SharePoint List Settings, and then to Form Settings and then select the Radio button one that shows Use the default SharePoint form. This would resolves the issue.



Wednesday, November 16, 2016

Enable and disable the Dashboard with SharePoint 2010 Developer

SharePoint 2010 Developer Dashboard

Developer dashboard can be used to check the performance and trace information, it can be used to debug and troubleshoot issues with page rendering time.  The dashboard is turned off by default, but can be enabled using stsadm.

 When the dashboard is turned on you will find information about the controls, queries and execution time that occur as part of the page rendering process; this information appears at the bottom of the page.

Run these below commands on PowerShell to set it to On/Off

To set it to On:
stsadm -o setproperty -propertyname developer-dashboard -propertyvalue On

To set it to Off:
stsadm -o setproperty -propertyname developer-dashboard -propertyvalue Off


Tuesday, October 18, 2016

You cannot access a WebDAV Web folder from a Windows-based client computer



Unable to browse large document library in explorer view


When Users are  trying to open SharePoint document library with many files(If document library contains more than 10,000 items) using explorer view they may get the following error message:

  \\server\webfolder\folder is not accessible. You might not have permission to
use this network resource.
Contact the administrator of this server to find
out if you have access permissions.

A device attached to the system is not functioning.


Solution:

To work around this problem, you need to modify the windows registry on the client computer.

Click Start, click Run, type regedit, and then click OK.
Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters\
Value:
FileAttributesLimitInBytes
Data Type: DWORD
Default Value: 1,000,000
decimal (1 MB)

Change the default value to a larger number, e.g. 100000000 for 100mb.

Exit Registry Editor

Restart WebClient service,

net stop webclient
net start webclient

Monday, October 17, 2016

PowerShell Script to List All Users who have access into document library in SharePoint site


Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$web = Get-SPWeb -Identity https://bw.bytes.co.za/applications/

$list = $web.Lists[“Client Billing”]
$siteCollUsers = $web.SiteUsers

$filename = "E:\Applications\application_usersxyz1.csv"

foreach($MyUser in $siteCollUsers)
{
#Write-Host ” ————————————- ”
#Write-Host “Site Collection URL:”, $SiteCollectionURL
if($list.DoesUserHavePermissions([Microsoft.SharePoint.SPBasePermissions]::ViewListItems,$MyUser) -eq $true)
{
#Write-Host “User : “, $MyUser.LoginName
#Write-Host “Assigned Permissions : “, $list.GetUserEffectivePermissions($MyUser.LoginName)

 "User:" + $MyUser.UserLogin +"     "+ "User Name: " +$MyUser.name + "     " + "Email: " +$MyUser.Email  | Out-File $filename -Append


}
#Write-Host ” ————————————- ”
}

Tuesday, October 11, 2016

PowerShell Script to List All Users in All Groups in SharePoint site(SharePoint 2010)

we can run below PowerShell script in SharePoint 2010 management Shell to get  List All Users in All Groups in SharePoint site.

Inputs : $siteUrl,  $filename


$siteUrl="site url"  # url name
$web = Get-SPWeb $siteUrl
$site = $web.Site
$rootWeb = $site.RootWeb
$filename = "E:\Applications\application_users.csv"    # file path name
foreach($group in $site.RootWeb.SiteGroups)
{
   "Group:" + $group.Name | Out-File $filename -Append
   foreach ($user in $group.Users)
   {
       "User:" + $user.UserLogin +"     "+ "User Name: " +$user.name + "     " + "Email: " +$user.Email  | Out-File $filename -Append
   }
}

Wednesday, September 14, 2016

Retreive ALL Service Accounts and Passwords via PowerShell


We can use below script to get all the service accounts passwords


Just copy the following script and paste it into an elevated/admin SharePoint PowerShell

#------------------------------------------------------------------------------------------
# Name:            Recover-SPManagedAccounts
# Description:    This script will retrieve the Farm Account credentials and show the
#                passwords for all of the SharePoint Managed Accounts
# Usage:        Run the script on a SP Server with an account that has Local Admin Rights
#
#------------------------------------------------------------------------------------------

#Checks if the Current PowerShell Session is running as the Administrator
if(([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") -eq $false){
    Throw "This Script must be ran as Administrator"
}

#This section retrives the Farm Account UserName/Password from the Security Token Service Application Pool
$Farm_user = C:\Windows\System32\cmd.exe /q /c $env:windir\system32\inetsrv\appcmd.exe list apppool "SecurityTokenServiceApplicationPool" /text:ProcessModel.UserName;
$Farm_pass = C:\Windows\System32\cmd.exe /q /c $env:windir\system32\inetsrv\appcmd.exe list apppool "SecurityTokenServiceApplicationPool" /text:ProcessModel.Password;
$Credential = New-Object System.Management.Automation.PsCredential($Farm_user, (ConvertTo-SecureString $Farm_pass -AsPlainText -Force));

# This line contains the script which returns the account passwords, script is from http://sharepointlonghorn.com/Lists/Posts/Post.aspx?ID=11
$GetManagedAccountPasswords = "
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0;
function Bindings(){
    return [System.Reflection.BindingFlags]::CreateInstance -bor
    [System.Reflection.BindingFlags]::GetField -bor
    [System.Reflection.BindingFlags]::Instance -bor
    [System.Reflection.BindingFlags]::NonPublic;
}
function GetFieldValue([object]`$o, [string]`$fieldName){
    `$bindings = Bindings;
    return `$o.GetType().GetField(`$fieldName, `$bindings).GetValue(`$o);
}
function ConvertTo-UnsecureString([System.Security.SecureString]`$string){
    `$intptr = [System.IntPtr]::Zero;
    `$unmanagedString = [System.Runtime.InteropServices.Marshal]::SecureStringToGlobalAllocUnicode(`$string);
    `$unsecureString = [System.Runtime.InteropServices.Marshal]::PtrToStringUni(`$unmanagedString);
    [System.Runtime.InteropServices.Marshal]::ZeroFreeGlobalAllocUnicode(`$unmanagedString);
    return `$unsecureString;
}
Get-SPManagedAccount | select UserName, @{Name='Password'; Expression={ConvertTo-UnsecureString (GetFieldValue `$_ 'm_Password').SecureStringValue}}";

#Writes the Script to the Public Folder (C:\Users\Public), this is required as we cant run the script inline as its too long.
Set-Content -Path "$($env:public.TrimEnd("\"))\GetManagedAccountPasswords" -Value $GetManagedAccountPasswords;

#The Script which will be ran in the new PowerShell Window running as the Farm Account, it also removes the script above which we wrote to the file system
$Script = "
`$Script = Get-Content `"$($env:public.TrimEnd("\"))\GetManagedAccountPasswords`";
PowerShell.exe -Command `$Script;
Remove-Item `"$($env:public.TrimEnd("\"))\GetManagedAccountPasswords`";
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0;"

#Runs PowerShell as the Farm Account and loads the Script above
Start-Process -FilePath powershell.exe -Credential $Credential -ArgumentList "-noexit -command $Script" -WorkingDirectory C:\