Am using the script below but getting the error message below. Does anyone know what is causing the issue?
Thanks,
Dan
ERROR MESSAGE:
-------------------------------------------------------------------
Trim : Method invocation failed because [Selected.Microsoft.Exchange.Management.TransportLogSearchTasks.MessageTrackingEvent] doesn't contain a method named 'Trim'.
At C:\Scripts\CC.PS1:37 char:24
+ $Rcpt1 += ($Entry).Trim <<<< ("{ }").Split(",")
+ CategoryInfo : InvalidOperation: (Trim:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
-------------------------------------------------------------------
Here is the script:
#DISCLAIMER ENDS#
#Start Customization Here#
$MbServer="SERVERNAME"
$StartFrom="08/01/2016 07:00:00"
$EndAt="08/08/2016 07:00:00"
$PathForOPFile="C:\SCRIPTS\"
#End Customization Here#
[String[]]$ExternalDomains= @()
$Site=(Get-ExchangeServer$MbServer).Site
$SiteToParse=$Site.Name
$Data=Get-ExchangeServer|Where-Object {$_.IsHubTransportServer
-eq$true-and$_.Site-Like"*$SiteToParse*"}|Get-MessageTrackingLog-ResultSize
Unlimited-EventIdReceive-Start
$StartFrom-end$EndAt|Where-object {($_.Recipients-ne$null) -and ($_.Source-eq"STOREDRIVER") -and ($_.ClientHostName-Like"*$MbServer*")}|Select-ObjectRecipients
[String[]]$Rcpt1= @()
Foreach ($Entryin
$Data)
{
$Rcpt1+= ($Entry).Trim("{ }").Split(“,”)
}
$RecipientDomList=$Rcpt1
Foreach ($Domainin
$RecipientDomList)
{
if ($Domain-NotLike"*@InternalDomain.Com")
{
$ExternalDomains+=$Domain.Split("@")[1]
}
}
$ExternalDomains|Group-Object|SelectName,Count|Export-CSV"$PathForOPFile \op.csv"–NoType