Dear Support,
i have following Problem:
If i exec this Scritp on the powershell of PRTG Server, everything works fine and i get all Values. But if i Run it with a PRTG Sensor ill get an Error, i wonder why the Script is Executed with the Computer Account of PRTG. OF COurse the XXXX are replaced with the Real Adresses and Server Names
---------------------------------------------------------------------------- param ( [String]$mailbox="xxxxxxxxx" ) #Exchange 2010 with current user $ExchangeOrNLBFQDN = "xxxxxx" $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://$ExchangeOrNLBFQDN/PowerShell/?SerializationLevel=Full" -Authentication Kerberos Import-PSSession $Session -DisableNameChecking -AllowClobber # Letzer Monat // Variablen mit -Start & -End können nicht in die Remote Session übergeben werden $CurrentDate = Get-Date $LastMonth = (($CurrentDate).AddMonths(-1)).ToUniversalTime().Month $LastMonthYear = (($CurrentDate).AddMonths(-1)).ToUniversalTime().Year $LastMonthName = $LastMonth | %{(Get-Culture).DateTimeFormat.GetMonthName($_)} $LastMonthDays = [DateTime]::DaysInMonth($LastMonthYear, $LastMonth) $StartOfPrevMonth = Get-Date -Month $LastMonth -Year $LastMonthYear -Day 1 -Hour 0 -Minute 0 -Second 0 $EndOfPrevMonth = ($StartOfPrevMonth).AddMonths(1).AddTicks(-1) # Abruf des Messagtrackinglogs $WeekCS = Get-Messagetrackinglog -Server $ExchangeOrNLBFQDN -Recipients $mailbox -Start $StartOfPrevMonth -End $EndOfPrevMonth -ResultSize unlimited -EventID RECEIVE $InternWeekCS=$WeekCS| where {($_.Sender -like "*@xxxxxx") -or ($_.Sender -like "*xxxxxxxx")} $ExternWeekCS=$WeekCS| where {($_.Sender -notlike "*x") -and ($_.Sender -notlike "*xxxxxxxx") } $AllWeekCS=$WeekCS $InternCountWeekCS=$InternWeekCS | measure $InternSumWeekCS14=$InternCountWeekCS.count $ExternCountWeekCS=$ExternWeekCS | measure $ExternSumWeekCS14=$ExternCountWeekCS.count $AllCountWeekCS=$AllWeekCS | measure $AllSumWeekCS14=$AllCountWeekCS.count #$AllSumWeekCS14 #$InternSumWeekCS14 #$ExternSumWeekCS14 #write-host "Sending XML Result to STDOUT" "<prtg> <result> <channel>Sendcount2</channel> <value>$AllSumWeekCS14</value> <showChart>1</showChart> <showTable>1</showTable> <unit>Count</unit> <customunit>Mails</customunit> <mode>Absolute</mode> </result> <result> <channel>Sendcount1</channel> <value>$InternSumWeekCS14</value> <showChart>1</showChart> <showTable>1</showTable> <unit>Count</unit> <customunit>Mails</customunit> <mode>Absolute</mode> </result><result> <channel>Sendcount</channel> <value>$ExternSumWeekCS14</value> <showChart>1</showChart> <showTable>1</showTable> <unit>Count</unit> <customunit>Mails</customunit> <mode>Absolute</mode> </result> </prtg>" ---------------------------------------------------------------------------------------
And here is the Result of the Sensor
----------------------------------------------------------------------------------------- New-PSSession : [ixxxxxxxt] Beim Verarbeiten von Daten vom Remoteserver "xxxxxxxxxxt" ist folgender Fehler aufgetreten: Benutzer "xxxxxx/xxxxx/PRTGServer" ist keiner Verwaltungsrolle zugewiesen. Weitere Informationen finden Sie im Hilfethema "about_Remote_Troubleshooting". In C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\GKS14.ps1:8 Zeichen:12 + $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "h ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:Re moteRunspace) [New-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : IncorrectProtocolVersion,PSSessionOpenFailed Import-PSSession : Das Argument fr den Parameter "Session" kann nicht berprft werden. Das Argument ist NULL. Geben Sie einen gltigen Wert fr das Argument an, und fhren Sie den Befehl erneut aus. In C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\GKS14.ps1:10 Zeichen:18 + Import-PSSession $Session -DisableNameChecking -AllowClobber + ~~~~~~~~ + CategoryInfo : InvalidData: (:) [Import-PSSession], ParameterBi ndingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power Shell.Commands.ImportPSSessionCommand Get-Messagetrackinglog : Die Benennung "Get-Messagetrackinglog" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausfhrbaren Programms erkannt. šberprfen Sie die Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang. In C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\GKS14.ps1:25 Zeichen:11 + $WeekCS = Get-Messagetrackinglog -Server $ExchangeOrNLBFQDN -Recipients $mailbox ... + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-Messagetrackinglog:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException <prtg> <result> <channel>Sendcount2</channel> <value>0</value> <showChart>1</showChart> <showTable>1</showTable> <unit>Count</unit> <customunit>Mails</customunit> <mode>Absolute</mode> </result> <result> <channel>Sendcount1</channel> <value>0</value> <showChart>1</showChart> <showTable>1</showTable> <unit>Count</unit> <customunit>Mails</customunit> <mode>Absolute</mode> </result><result> <channel>Sendcount</channel> <value>0</value> <showChart>1</showChart> <showTable>1</showTable> <unit>Count</unit> <customunit>Mails</customunit> <mode>Absolute</mode> </result> </prtg>
Add comment