Tuesday, June 18, 2013

Shrink MS SQL Server log files

I have SharePoint farm running on my machine. Have memory and space limitations. In this situation most of the time receive alert running out of space. After investigation find that SharePoint Content database log files are taking lots of space in GBs.

So, you can reduce log files size through SQL server management studio. just need to follow some simple steps.

Navigate to physical location where SQL server files are stored. Path will be : C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA

You can recognise, files those have _log in the end are log files. And file type of these files are “SQL Server Database Transaction Log File”.  Here I’ve got one WSS_Content database file which I will find in SQL server management studio.




Now I open SQL server management studio and look for above file.

and here it is. Right click on database file navigate to Task > Shrink > Files.




Click on Files.

Select File type : Log




Click OK.

You will see the log file size is reduced in KBs.



Wednesday, April 10, 2013

Download PowerShell Integrated Scripting Environment (ISE) for Windows Server 2008R2

Windows PowerShell Integrated Scripting Environment (ISE) is a host application that enables you to write, run, and test scripts and modules in a graphical and intuitive environment.

It is shipped as feature with Windows Server 2008R2 and you can install it from Feature Role.

for that Open Server Manager >> Select Features Option >>  Select Add Features

Add Feature

Click Next and Install

Install ISE

Instal ISE Process

Install ISE Done

To open PowerShell ISE click on Start and type PowerShell ISE.


Sunday, March 31, 2013

Create OU in Active Directory using PowerShell

Here I’ve written code for creating OU in Active directory.
First of all will get Domain name and pass Distinguished name to function DNStoDN.
   1: function PassPath

   2: {


   4:     $DC = Convert-DNStoDN (gwmi WIN32_ComputerSystem).Domain


   6:     return "OU=$OU, $DC"

   7: }

Then split DistinguishedName using function DNStoDN

   1: # This function to get 
   2: function Convert-DNStoDN ([string]$DNSName) 
   3: { 
   4:    #  Create an array of each item in the string separated by "." 
   5:    $DNSArray = $DNSName.Split(".") 
   6:   # Let's go through our new array and do something with each item 
   7:    for ($x = 0; $x -lt $DNSArray.Length ; $x++) 
   8:       { 
   9:         #I don't want a comma after my last item, so check to see if I am on my last one and set 
  10:         # $Separator equal to nothing. 
  11:         # Remember that we need to go to Length-1 because arrays are "0 based indexes" 
  12:          if ($x -eq ($DNSArray.Length - 1)){$Separator = ""}else{$Separator =","} 
  13:          [string]$DN += "DC=" + $DNSArray[$x] + $Separator 
  14:       } 
  15:    return $DN 
  16: }

Now I’ll check OU is exists, If it does not will create new OU. You can change the name of OU given in the beginning.


   2: function CheckOU

   3: {

   4: [string] $path = PassPath  #Calling function PassPath

   5: [string] $fPassPath = Convert-DNStoDN (gwmi WIN32_ComputerSystem).Domain

   6: try {

   7:      if(([adsi]::Exists("LDAP://$fPassPath")))

   8:      {

   9:         #return $true #Throw("Supplies Path does not exists.")

  10:         if(([adsi]::Exists("LDAP://$path")))

  11:         {

  12:             return $true

  13:         }

  14:      }    

  15:     }

  16: catch {

  17:        Write-Host "Please check Domain of your machine" -ForegroundColor red  

  18:        exit   

  19:       }

  20: }


  22: if((CheckOU))

  23: {

  24:     Write-Host "OU exits"

  25: }

  26: else

  27: {

  28: try {

  29:         [string] $fPassPath = Convert-DNStoDN (gwmi WIN32_ComputerSystem).Domain

  30:         Write-Host $fPassPath

  31:         if(([adsi]::Exists("LDAP://$fPassPath")))

  32:         {

  33:             $Connect = [adsi]"LDAP://$fPassPath"


  35:             $CreateOU = $Connect.Create("OrganizationalUnit","OU= $OU")

  36:             $CreateOU.SetInfo()

  37:             if((CheckOU))

  38:             {

  39:                 Write-Host "`nOU" $OU " has been created!"  -ForegroundColor green




  43:             }

  44:         }

  45:     }

  46: catch {

  47:          Write-Host "Can't create OU." -ForegroundColor red

  48:          exit

  49:       }

  50: }

Here is the complete code snippet.

Run this script with Administrator privilege.

   1: Import-Module ActiveDirectory
   3: $OU = "myOU" # Organizational Unit Name
   6: # This function to get 
   7: function Convert-DNStoDN ([string]$DNSName) 
   8: { 
   9:    #  Create an array of each item in the string separated by "." 
  10:    $DNSArray = $DNSName.Split(".") 
  11:   # Let's go through our new array and do something with each item 
  12:    for ($x = 0; $x -lt $DNSArray.Length ; $x++) 
  13:       { 
  14:         #I don't want a comma after my last item, so check to see if I am on my last one and set 
  15:         # $Separator equal to nothing. 
  16:         # Remember that we need to go to Length-1 because arrays are "0 based indexes" 
  17:          if ($x -eq ($DNSArray.Length - 1)){$Separator = ""}else{$Separator =","} 
  18:          [string]$DN += "DC=" + $DNSArray[$x] + $Separator 
  19:       } 
  20:    return $DN 
  21: }
  24: function CheckOU
  25: {
  26: [string] $path = PassPath  #Calling function PassPath
  27: [string] $fPassPath = Convert-DNStoDN (gwmi WIN32_ComputerSystem).Domain
  28: try {
  29:      if(([adsi]::Exists("LDAP://$fPassPath")))
  30:      {
  31:         #return $true #Throw("Supplies Path does not exists.")
  32:         if(([adsi]::Exists("LDAP://$path")))
  33:         {
  34:             return $true
  35:         }
  36:      }    
  37:     }
  38: catch {
  39:        Write-Host "Please check Domain of your machine" -ForegroundColor red  
  40:        exit   
  41:       }
  42: }
  44: if((CheckOU))
  45: {
  46:     Write-Host "OU exits"
  47: }
  48: else
  49: {
  50: try {
  51:         [string] $fPassPath = Convert-DNStoDN (gwmi WIN32_ComputerSystem).Domain
  52:         Write-Host $fPassPath
  53:         if(([adsi]::Exists("LDAP://$fPassPath")))
  54:         {
  55:             $Connect = [adsi]"LDAP://$fPassPath"
  57:             $CreateOU = $Connect.Create("OrganizationalUnit","OU= $OU")
  58:             $CreateOU.SetInfo()
  59:             if((CheckOU))
  60:             {
  61:                 Write-Host "`nOU" $OU " has been created!"  -ForegroundColor green
  65:             }
  66:         }
  67:     }
  68: catch {
  69:          Write-Host "Can't create OU." -ForegroundColor red
  70:          exit
  71:       }
  72: }


Thursday, March 14, 2013

SharePoint 2010 Service Account Password Change

My SharePoint Farm has multiple application pools including SharePoint Services running.

And each Application Pool is running on different service account.

To check which application pool is running using which service account.

Go to Run >> Type inetmgr. This will open Internet Information Services Manager.

Click on Application Pool and you can see Identity of Application pool which is Service account.


When we create Application Pool or Application Service and choose new service application pool account, this account

get registered to Manage Accounts under Security.

Path will be Central Administration >  Security > Manage Accounts

We can see here are all service accounts are registered.

Manage Accounts

If you want to Check password of service account you can check using PowerShell command.

Open Windows PowerShell Module from All Application Program.

type below PowerShell Command.

Get-WmiObject –Namespace root/MicrosoftIIsV2 –Class IIsApplicationPoolSetting –Property Name, WAMUserName, WAMUserPass | Select Name, WAMUserName, WAMUserPass

and it will show all passwords of particular service account name.


This will help you in case you forget your AppPool Service Account password.

Now, we will change password of service account which is running a web application name Tesst – 45380. And you can see

the service account name is spdev\testpass and password is P@ssw0rd3

For changing password of spdev\testpass  go to Central Administration > Security > Manage Accounts

look for spdev\testpass and edit.

Now check box named Change Password Now and select Set account password to new value.

enter new password and click on ok.



To confirm password is changed or not you can run above PowerShell script.


Thanks for reading,

Any query, please post comment.


Tuesday, December 25, 2012

Install and Configure SharePoint Server 2013 step by step

In this blog post I am covering all basic required steps of SharePoint 13 installation. And have divided this in 4 parts.

1) Install Windows Server 2012 and Active Directory configuration.

2) Install SQL Server 2012.

3) Install and configure SharePoint Server 2013 .

4) Configure SharePoint Server Service Applications

5) Create your first web application on SharePoint Server 2013.

Installation and configuration of Windows Server and SQL server have done more specific to build SharePoint Server farm prospective.

For example, Permissions given to Service accounts during installation of windows server. Installation of SQL server and SharePoint Server have done by specific service account.

If you have any query, please post comment.

Thank you.


Create Web Application on SharePoint Server 2013

This blog post is specially for SharePoint beginners. If you have read my previous blog about SharePoint Server 13 installation and configuration. This blog is about creating web application and creating site collection.

So let’s open SharePoint Central Administration Page.

Navigate to Manage Web Applications >> Click on New

IIS web site name : <Enter name>

Select Port : ( I don’t have any web application created before, So it’s taking port 80)



Application Pool Name : <Enter name>

note : I am going to create Team Site under this web application, So I’ve given TeamSite name to Application name and 80 to remember this application pool is on port 80.




Content Database name : I’ve added _80 to differentiate in Content database.


We can select Service Application those will be connected to web application we are creating.


Click on OK to create web application. This will take few seconds.

Once the web applicaiton is created. Go to Application Management >> Create Site Collection

Select Web Application which was just created.

Title : <Enter name>


Select Template : Team Site

Select Experience Version : 2013

Primary site collection administrator : spadmin


note : primary and secondary admin have full permission on site collection.

click on Ok.

Visit just created Team site collection.


Give permissions to Active Directory users to site collection.

Navigate to Site Contents which is on left panel of the Team Site.


Again go to Settings


People and groups

Add new user to Team site members this group has contribute permission Type >> NT Authority\authenticated users


Go to home page by clicking on Team site link and sign in with different user.


Also read :