Sending email using Powershell script

   Below is a script that can be used to send email using Powershell.  function sendMail{      Write-Host “Sending Email”      #SMTP server name     $smtpServer = “”      #Creating a Mail object     $msg = new-object Net.Mail.MailMessage      #Creating SMTP server object     $smtp = new-object Net.Mail.SmtpClient($smtpServer)      #Email structure      $msg.From = ““     $msg.ReplyTo = ““    …


PreUpgradeCheck does not run

Issue: In some occasion while trying to run the PreUpgradeCheck command it throw below error: Pre-upgrade check cannot proceed because the current farm is not joined to a farm, or the farm configuration database is not responding. Resolution: This error is probably that you don’t have the sufficient privileges to run the command, so run…


Creating table using Powershell

Below is a sample script to create a datatable using powershell.$tabName = “SampleTable”#Create Table object$table = New-Object system.Data.DataTable “$tabName”#Define Columns$col1 = New-Object system.Data.DataColumn ColumnName1,([string])$col2 = New-Object system.Data.DataColumn ColumnName2,([string])#Add the Columns$table.columns.add($col1)$table.columns.add($col2)#Create a row$row = $table.NewRow()#Enter data in the row$row.ColumnName1 = “A” $row.ColumnName2 = “1” #Add the row to the table$table.Rows.Add($row)#Display the table$table | format-table -AutoSize #NOTE:…


How to add Active Directory module in PowerShell in Windows 7

If you are planning to run a Powershell script with Active Directory commandlets on a Win 7 machine or any other machine that DOES NOT have AD role then you need to do some preliminary steps as listed below.   Step1:   By default one can not import Active Directory module in Powershell in Windows…


Creating log files in Powershell scripts

I was working on a project in which I had to create a script to do some solution deployment, site creations etc., and while doing these the script shoul create log file to log entire process. This is a sample script which i worked out and could be useful to all needy. This script has…


Powershell script to generate an excel report to list the applications and patches installed

This is a Powershell script to create a report in excel listing all the applications and patches installed  in the local machine. The report will have following information: 1st sheet will have Application Name and Application Version. 2ns sheet will have KB and Description The script is attached as a file to this blog, please…


"Failed to create sample data" – SharePoint 2010 PSConfig fails in Windows 7

ISSUE: While installing SharePoint 2010 on Windows 7 OS, it fails while running psconfig wizard at step 8th with below screen. [Failed to create sample data. An exception of type Microsoft.SharePoint.SPException was thrown.  Additional exception information: User cannot be found. Microsoft.SharePoint.SPException: User cannot be found.]  


Installing and Configuring SharePoint 2010 through Powershell

Installing and Configuring SharePoint 2010 through Powershell Scripting STEP1: Preparation Download the SPModule and add the same folder location to the PSModulePath in Environmental variables of respective server as shown below:     #Restart the server before installing SP2010 Restart-Computer -force   STEP2: Installation. I have named this file as SP1.PS1. ==================================== SP1.ps1 [PowerShell -File…