PowerShell script to find the hotfix installed and its details on the server:
The report will have the below contents:
1. Current SharePoint build versions.
2. Hot Fix ID.
3. Who installed the hot fix?
4. When was the hot fix installed?
Edit the script to pass on the server names, from, to and SMTP address to send an email on the hotfix report. Download the attached file to get the .css file for the report.
- $LogTime = Get-Date -Format yyyy-MM-dd_hh-mm
- $LogFile = ".\HotFixReportPatch-$LogTime.rtf"
-
- # Add SharePoint PowerShell Snapin
-
-
- if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) {
- Add-PSSnapin Microsoft.SharePoint.Powershell
- }
-
- $scriptBase = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent
- Set-Location $scriptBase
-
-
- #Deleting any .rtf files in the scriptbase location
- $FindRTFFile = Get-ChildItem $scriptBase\*.* -include *.rtf
- if($FindRTFFile)
- {
- foreach($file in $FindRTFFile)
- {
- remove-item $file
- }
- }
-
-
- start-transcript $logfile
-
- #Get All the Servers where you need to find the hot fix report
- #$Servers = @("server1" , "server2")
- $Servers = @("Server names")
-
- #Get the hot-fix in a variable for desired output
- $HotFixDetails = Get-HotFix -ComputerName $servers | Select CSName , HotFixID , InstalledOn , InstalledBy , Caption , Description | ConvertTo-Html -Fragment
- ConvertTo-Html -Body "$HotFixDetails" -CssUri $scriptbase\style.CSS | Out-File $scriptbase\HotFix.html
- write-host "The output is in the location $scriptbase\HotFix.html" -fore green
-
-
- #Send Mail
- $SMTP = "Your SMTP Server Name"
- $From = "From Adddress"
- $To = "To Adddress"
-
- Send-MailMessage -SmtpServer $SMTP -From $From -To $To -Subject "SharePoint Hot Fix Installation Report" -Attachments $scriptbase\HotFix.html
- write-host "Email with hotfix informations sent to $To" -fore cyan