Monday, November 18, 2013

Get Concurrent User list from IIS


1.       Enable the IIS Logs in the Server.
2. After Enable the log. Need to check whether the Fields are enabled or not.

3. Select your appropriate fields
4. After completed the above steps, need to install the “LogParser” tool to our server.
The log parser can be downloaded from the below location
5. Run “getConcurrentUser.bat” file.
code in bat file:
----------------------------------------------------------------------------------------------------------------------------------
cd\
c:
if exist c:\concurrentUser goto use_e
md concurrentUser
:use_e
cd C:\Program Files (x86)\Log Parser 2.2
set hr=%time:~0,2%
if "%hr:~0,1%" equ " " set hr=0%hr:~1,1%
set fdtm=%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%
set fpath=c:\concurrentUser\userList_%fdtm%.csv
logparser -i:IISW3C -o:CSV "select distinct cs-username from C:\inetpub\logs\LogFiles\*.log" >%fpath% -recurse
Powershell.exe -executionpolicy remotesigned -File C:\britto\iislogdec\sendEmail.ps1 %fpath%
pause
-----------------------------------------------------------------------------------------------------------------------------
6. can able to get the output file from  “c:\concurrentUser” path. This “CSV” file is generated in the name of “userList_<current Date and Time>.csv”
7. To send this report to email through power shell (save file name as sendEmail.ps1)
###########Define Variables######## 

$fromaddress = "bretto.be@gmail.com" 
$toaddress = "bretto.be@gmail.com" 
$bccaddress = "bretto.be@gmail.com" 
$CCaddress = "bretto.be@gmail.com" 
$Subject = "Concurrent user report" 
#$body = get-content .\content.htm 
$body = "Please find the Concurrent user report file" 
$attachment =$args[0] 
$smtpserver = "smtp.gmail.com" 

#################################### 

$message = new-object System.Net.Mail.MailMessage 
$message.From = $fromaddress 
$message.To.Add($toaddress) 
$message.CC.Add($CCaddress) 
$message.Bcc.Add($bccaddress) 
$message.IsBodyHtml = $True 
$message.Subject = $Subject 
$attach = new-object Net.Mail.Attachment($attachment) 
$message.Attachments.Add($attach) 
$message.body = $body 
$smtp = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$smtp.EnableSsl = $true

$smtp.Credentials = New-Object System.Net.NetworkCredential("bretto.be@gmail.com", "xyz");
$smtp.Send($message) 

#################################################################################

run the batch file we will get the mail with attachment.

Wednesday, November 13, 2013

Steps to Activate the custom timer job => Access denied when deploying a timer Job or activating a feature from SharePoint 2010 content web application


The following step i have used to followed to active the timer job.

Step 1: run the script in powershell command
function Set-RemoteAdministratorAccessDenied-False()
{
    # load sharepoint api libs
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration") > $null

  # get content web service
 $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
  # turn off remote administration security
 $contentService.RemoteAdministratorAccessDenied = $false
  # update the web service
 $contentService.Update()
     
}

Set-RemoteAdministratorAccessDenied-False

step 2: activate the timer job feature in site collection feature.