How to enable verbose log mode on Sharepoint 2010

First Method: Using Central Administration

1) Open your Central Administration
2) Click Monitoring and Click “Configure Diagnostic Logging”

3) Select “All Categories” and
Select “Verbose” for “Least critical event to report to the event log”
Select “Verbose” for “Least critical event to report to the trace log”

4) Click Ok.

Important!:Please don’t forget change mode to default after collecting needed verbose mode logging. Because in verbose mode log files grows rapidly and if you are not enough storage your sharepoint server would be crashed.

Important!:Before enabling verbose mode ensure you have enough hdd space on ALL your servers. Because this is a farm configuration and all servers has been affected by this change.

For more information about levels :
http://technet.microsoft.com/en-us/library/ee748656.aspx

Second Method: Using PowerShell

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.
  2. On the Start menu, click All Programs.
  3. Click Microsoft SharePoint 2010 Products.
  4. Click SharePoint 2010 Management Shell.
  5. At the Windows PowerShell command prompt (that is, PS C:\>), type the following command, and then press ENTER:Set-SPLogLevel -TraceSeverity {None | Unexpected | Monitorable | Medium | High | Verbose} -EventSeverity {None | Information | Warning | Error | Critical | Verbose} [-Identity <Category name…>]  -VerboseYou can use the Identity parameter to specify one or more categories to change — for example, Administration. If you do not specify the value for the Identityparameter, all categories are changed.To view the current settings, type Get-SPLogLevel, and then press ENTER.To set all categories back to default levels, type Clear-SPLogLevel, and then press ENTER.

For Example set all logs to verbose use fallowing command:
Set-SPLogLevel  -TraceSeverity Verbose -EventSeverty Verbose

You can find Sharepoint logs in folder: (Default folder)
Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extentions\14\LOGS
NOTE: If you need to transfer these files to Microsoft File Services , please compress files in zip file. If zip file size is bigger than  5GB please spearate multiple files that lower than 5GB.

Please read Logging Best Practices from MSDN

The SharePoint Server 2010 environment might require configuration of the diagnostic loggings settings after initial deployment or upgrade and possibly throughout the system’s life cycle. The guidelines in the following list can help you form best practices for the specific environment.

  • Change the drive that logging writes to. By default, diagnostic logging is configured to write logs to the same drive and partition that SharePoint Server 2010 was installed on. Because diagnostic logging can use lots of drive space and writing to the logs can affect drive performance, you should configure logging to write to a drive that is different from the drive on whichSharePoint Server 2010 was installed. You should also consider the connection speed to the drive that logs are written to. If verbose-level logging is configured, lots of log data is recorded. Therefore, a slow connection might result in poor log performance.
  • Restrict log disk space usage. By default, the amount of disk space that diagnostic logging can use is not limited. Therefore, limit the disk space that logging uses to make sure that the disk does not fill up, especially if you configure logging to write verbose-level events. When the disk restriction is used up, the oldest logs are removed and new logging data information is recorded.
  • Use the Verbose setting sparingly. You can configure diagnostic logging to record verbose-level events. This means that the system will log every action that SharePoint Server 2010 takes. Verbose-level logging can quickly use drive space and affect drive and server performance. You can use verbose-level logging to record a greater level of detail when you are making critical changes and then re-configure logging to record only higher-level events after you make the change.
  • Regularly back up logs. The diagnostic logs contain important data. Therefore, back them up regularly to make sure that this data is preserved. When you restrict log drive space usage, or if you keep logs for only a few days, log files are automatically deleted, starting with the oldest files first, when the threshold is met.
  • Enable event log flooding protection. Enabling this setting configures the system to detect repeating events in the Windows event log. When the same event is logged repeatedly, the repeating events are detected and suppressed until conditions return to a typical state.
Advertisements

Sharepoint 2010 Change your display of wellcome name

Instead of configure user profile syncronization and getting full dump some of users shown name has not able to change and still show user’s account name.Some scenarios it should be possible and if you want to change it manually there is a way to do it using powershell script on one site.

Set-SPuser -identity “DOMAIN\accountname” -DisplayName “Name Surname” -web <URL of Site>
Example:
Set-SPUser -identity “BLOG\admin” -DisplayName “Bugra POSTACI” -web http://blog.bugrapostaci.com

And also you can use by syncAD option .
Set-SPUser -Identity “DOMAIN\accountname”  -SyncFromAD  -web <URL of Site>
Example:
Set-SPUser -identity “BLOG\admin” -SyncFromAD -web http://blog.bugrapostaci.com

But what if your boss want you to add extra necessity to join your name with your title.
Like:
Bugra POSTACI ( Senior Sharepoint Support Engineer)

you can use this powershell script:

#Add SharePoint PowerShell SnapIn if not already added
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$site = new-object Microsoft.SharePoint.SPSite("http://blog.bugrapostaci.com");
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);

$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
$AllProfiles = $ProfileManager.GetEnumerator()

foreach($profile in $AllProfiles)
{
     $Title = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::Title].Value
     $AccountName= $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value
     $PreferredName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::PreferredName].Value

     if( $PreferredName -ne "None" -and $Title -ne $null )
     {
          write-host "Profile: ", $PreferredName,"(",$Title,")"
          $dName = $PreferredName + " (" + $Title + ")"
          #you can add update your users displayname like below
          Set-SPUser -identity $AccountName -Displayname $dName -web http://blog.bugrapostaci.com
     }
}

write-host "Finished."
$site.Dispose()

If you just want to update all content database userinfo table with profile user names . You can use fallowing script.

#Add SharePoint PowerShell SnapIn if not already added
 if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
 Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

if( $args.Length -eq 0) {
write-host "Usage : Missing <URL>"
exit
}

$site = new-object Microsoft.SharePoint.SPSite($args[0]);
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);
$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
$AllProfiles = $ProfileManager.GetEnumerator()

foreach($profile in $AllProfiles)
{
    $AccountName= $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value
    $PreferredName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::PreferredName].Value

    if( $PreferredName -ne "NONE" )
    {  
         write-host "Profile: ", $PreferredName , $Accountname
         Set-SPUser -identity $AccountName -Displayname $PreferredName -web $args[0]
         write-host "OK"
    } 
}
write-host "Finished."
$site.Dispose()

Have a nice scripting …

Installation of Sharepoint Diagnostic Log Compression (DLC) v1.0

Install via Sharepoint Management Console (PowerShell)

  1. Download Diagnostic Log Compression from http://dlc.codeplex.com and  Copy wsp file to c:\ drive
  2. Adding solution to solution storeAdd-SPSolution -LiteralPath C:\DiagnosticLogCompression.wsp
  3. Deploy SolutionInstall-SPSolution -Identity diagnosticlogcompression.wsp –GACDeployment
  4. Enable Feature for Central Administration application

Enable-SPFeature -Identity 0ed55cf5-5322-44bb-b5bf-9126130f7d38 -url <Your Central administration url and port>

  1. Restart Sharepoint Timer Servicenet stop sptimerv4
    net start sptimerv4

 

Install via stsadm tool

1. Download Diagnostic Log Compression from dlc.codeplex.com and Copy wsp file to c:\

2. Add Solution to solution store

stsadm -o addsolution -filename c:\DiagnosticLogCompression.wsp

3. Deploy solution

stsadm -o deploysolution -name DiagnosticLogCompression.wsp -immediate –allowgacdeployment

4. Execute Admin Service jobs

stsadm -o execadmsvcjobs

5. Enable Diagnostic Log Compression Feature

stsadm -o activatefeature -id 0ed55cf5-5322-44bb-b5bf-9126130f7d38 -url

6. Restart Sharepoint Timer Service

net stop sptimerv4
net start sptimerv4

  Cheers 🙂

how to delete sharepoint timer job using powershell

When developing custom sharepoint timer jobs sometimes you want to delete junk jobs created by deployment attempts .

Warning !!! DO NOT DELETE ANY TIMER JOB UNLESS BE SURE

Searching listing and find timer job to delete.We need an id.
Get-SPTimerJob | where { $_.name -like “*<your search criteria>*” } |ft id,name

Set job to a variable
$job = Get-SPTimerJob -id <GUID>

And delete it.
$job.Delete()

just it.

Getting installed powershell version

Ok. you have powershell but you dont know what is the version of it ?
Just write “$host.version” than press enter 🙂

Checking Replication Directory Changes for account by PowerShell

This power shell script checks Replication Directory Changes rights for specific user. You can use this script for detect sharepoint 2010 user profile service account has correct rights

Important !!!: this script not work with Domain Administrator’s accounts .

#Save to script a file named CheckRDC.ps1
usage syntax:
open Sharepoint 2010 PowerShell Console
PS> .\CheckRDC.ps1 “DOMAIN\username”

param( [string] $userName="")
function Check-ADUserPermission(
    [System.DirectoryServices.DirectoryEntry]$entry, 
    [string]$user, 
    [string]$permission)
{
    $dse = [ADSI]"LDAP://Rootdse"
    $ext = [ADSI]("LDAP://CN=Extended-Rights," + $dse.ConfigurationNamingContext)

    $right = $ext.psbase.Children | 
        ? { $_.DisplayName -eq $permission }

    if($right -ne $null)
    {
        $perms = $entry.psbase.ObjectSecurity.Access |
            ? { $_.IdentityReference -eq $user } |
            ? { $_.ObjectType -eq [GUID]$right.RightsGuid.Value }

        return ($perms -ne $null)
    }
    else
    {
        Write-Warning "Permission '$permission' not found."
        return $false
    }
}

# Globals

$replicationPermissionName = "Replicating Directory Changes"

# Main()

$dse = [ADSI]"LDAP://Rootdse"

$entries = @(
    [ADSI]("LDAP://" + $dse.defaultNamingContext),
    [ADSI]("LDAP://" + $dse.configurationNamingContext));

Write-Host "User '$userName': "
foreach($entry in $entries)
{
    $result = Check-ADUserPermission $entry $userName $replicationPermissionName

    if($result)
    {
        Write-Host "`thas a '$replicationPermissionName' permission on '$($entry.distinguishedName)'" `
            -ForegroundColor Green
    }
    else
    {
        Write-Host "`thas no a '$replicationPermissionName' permission on '$($entry.distinguishedName)'" `
            -ForegroundColor Red
    }
}

The synchronization account for a connection to Active Directory Domain Services (AD DS) must have the following permissions:

It must have Replicate Directory Changes permission on the domain that you will synchronize with. See Grant Replicate Directory Changes permission on a domain for instructions to grant this permission.

If the domain controller is running Windows Server 2003, the synchronization account must be a member of the Pre-Windows 2000 Compatible Access built-in group. See Add an account to the Pre-Windows 2000 Compatible Access group for instructions to grant this permission.

If the NetBIOS name of the domain differs from the domain name, the synchronization account must have Replicate Directory Changes permission on the cn=configuration container. See Grant Replicate Directory Changes permission on the cn=configuration container for instructions to grant this permission.

If you will export property values from SharePoint Server to AD DS, the synchronization account must have Create Child Objects (this object and all descendants) and Write All Properties (this object and all descendants) permissions on the organizational unit (OU) that you are synchronizing with. See Grant Create Child Objects and Write permission for instructions to grant this permission.

for more info :
http://technet.microsoft.com/en-us/library/ee721049.aspx

Sharepoint 2010 Delete all imported profile users by PowerShell

#PowerShell Script - Delete All User Profiles - SharePoint 2010
#The scripts is distributet "as-is." Use it on your own risk. The author give no warranties, guarantees or conditions.
 
 #Add SharePoint PowerShell SnapIn if not already added
 if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}


$site = new-object Microsoft.SharePoint.SPSite("http://blog.bugrapostaci.com:8090");  
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);  

#Get UserProfileManager from the My Site Host Site context
$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)  
$AllProfiles = $ProfileManager.GetEnumerator()  

foreach($profile in $AllProfiles)  
{  
    $DisplayName = $profile.DisplayName  
    $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value  
   
    #Do not delete setup (admin) account from user profiles. In this case account is 
    if($AccountName -ne "BLOG\Mossadmin")
    {
        $ProfileManager.RemoveUserProfile($AccountName); 
        write-host "Profile for account ", $AccountName, " has been removed"
    }

}  
write-host "Finished." 
$site.Dispose() 

note:this code is not belong to me thanks for that . I changed it a little .)