SharePoint常用Powershell整理

SharePoint问题排查

案例1,邮件问题,邮件已在后台进行配置好,可是还是无法发送,所以需要知道无法发送的原因,可以通过查询ULS(Unified Logging System)

对邮件发送日志中反馈的问题进行分析

$SiteURL="https://sharepointtest.centos.com/"
$Email = "Test@SharePoint.com"
$Subject = "Test Email from SharePoint"
$Body = "Test Email Body"
#Get the Web
$Web = Get-SPWeb $SiteURL
 
#Send Email using SPUtility SendEmail method
[Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($Web ,0,1,$Email,$Subject,$Body)
Get-SPLogEvent -StartTime "12/30/2021 15:32" -EndTime "12/31/2021 11:20" | Where-Object {$_.Category -eq "E-Mail"} |select Message |ft -wrap >>D:\Logs\1230.txt

$EmailTo = "test@centos.com"
$EmailSubject = "Test Email from SharePoint"
$EmailBody = "Test Email Body"

$SPGlobalAdmin = New-Object Microsoft.SharePoint.Administration.SPGlobalAdmin
$SMTPServer = $SPGlobalAdmin.OutboundSmtpServer
$EmailFrom = $SPGlobalAdmin.MailFromAddress

Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $EmailSubject -Body $EmailBody -BodyAsHtml -SmtpServer $SmtpServer -UseSsl

#邮件发送
$EmailTo = "test@centos.com"
$EmailSubject = "Test Email from SharePoint"
$EmailBody = "Test Email Body"

$SMTPServer = "10.10.5.19"
$SMTPServer = "mail.centos.com"
$EmailFrom = "SharePoint@centos.com"

#匿名
Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $EmailSubject -Body $EmailBody -BodyAsHtml -SmtpServer $SmtpServer -UseSsl
#不匿名
Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $EmailSubject -Body $EmailBody -BodyAsHtml -SmtpServer $SmtpServer -Credential SharePoint.Notify@hengrui.com



$SiteURL="https://sharepoint.sha.centos.com/"
$Email = "test@hengrui.com"
$Subject = "Test Email from SharePoint"
$Body = "Test Email Body"

#Get the Web
$Web = Get-SPWeb $SiteURL

#Send Email using SPUtility SendEmail method
[Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($Web ,0,1,$Email,$Subject,$Body)

Set-ContentFilterConfig -BypassedSenders SharePoint.Notify@hengrui.com


$SPGlobalAdmin = New-Object Microsoft.SharePoint.Administration.SPGlobalAdmin
$SPGlobalAdmin.OutboundSmtpServer


Get-MessageTrackingLog -Start "12/28/2021 09:00:00" -End "12/31/2021 17:00:00" -Sender "SharePoint@centos.com"


$SiteURL="https://sharepointtest.centos.com/"
$Email = "test@centos.com"
$Subject = "Taomg Email from SharePoint"
$Body = "Taomg Email Body"

#Get the Web
$Web = Get-SPWeb $SiteURL

#Send Email using SPUtility SendEmail method
[Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($Web ,0,1,$Email,$Subject,$Body)


Get-SPLogEvent -StartTime "12/30/2021 15:00" -EndTime "12/31/2021 11:20" | Where-Object {$_.Category -eq "E-Mail"} |select Message |ft -wrap >>D:\Logs\zhengshi.txt

原文地址:https://www.cnblogs.com/life512/p/15749029.html