Hi Guys,
I do not see what is not correct about this xml output...
This is the code in powershell :
#-----Please adjust to your Exchange server: $CURI="http://myserver/PowerShell/" #-------------- Function SizeInBytes ($itemSizeString) { $posOpenParen = $itemSizeString.IndexOf("(") + 1 $numCharsInSize = $itemSizeString.IndexOf(" bytes") - $posOpenParen $SizeInBytes = $itemSizeString.SubString($posOpenParen,$numCharsInSize).Replace(",","") return $SizeInBytes } $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $CURI -Authentication Kerberos Import-PSSession $Session -DisableNameChecking $dbs = Get-MailboxDatabase -Status $result+="<prtg>`r`n" foreach($db in $dbs) { $dbname=$db.name $dbsize=SizeInBytes($db.DatabaseSize) $whitespace=SizeInBytes($db.availablenewmailboxspace) $edbFilePath = ("\\"+$db.ServerName+"\"+ $db.EdbFilePath.tostring().replace(":","$")) $i = $edbFilePath.LastIndexOf('\') $edbFilePath = $edbFilePath.Remove($i+1) $guid = $db.Guid.ToString() $dir = (get-childitem $edbFilePath | where { $_.Name.Contains($guid) }) $idxdir=$edbFilePath+$dir $idxsize=(Get-ChildItem $idxdir | Measure-Object -Property Length -Sum).Sum $result+=" <result>`r`n" $result+=" <channel>DB-Size "+$dbname+"</channel>`r`n" $result+=" <unit>BytesFile</unit>`r`n" $result+=" <value>"+$dbsize+"</value>`r`n" $result+=" </result>`r`n" $result+=" <result>`r`n" $result+=" <channel>Whitespace "+$dbname+"</channel>`r`n" $result+=" <unit>BytesFile</unit>`r`n" $result+=" <value>"+$whitespace+"</value>`r`n" $result+=" </result>`r`n" $result+=" <result>`r`n" $result+=" <channel>Size Index "+$dbname+"</channel>`r`n" $result+=" <unit>BytesFile</unit>`r`n" $result+=" <value>"+$idxsize+"</value>`r`n" $result+=" </result>`r`n" } $result+="</prtg>`r`n" $result Exit 0
My result
PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\Luktdit.ps1 ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Script 1.0 tmp_0odkiko5.l0w {Add-ADPermission, Add-AvailabilityAddressSpace, Add-ContentFilterPhrase, Add-DatabaseAvailabilityGroupServer...} <prtg> <result> <channel>DB-Size Mailbox Database 1820752587</channel> <unit>BytesFile</unit> <value>1072275456000</value> </result> <result> <channel>Whitespace Mailbox Database 1820752587</channel> <unit>BytesFile</unit> <value>24879923200</value> </result> <result> <channel>Size Index Mailbox Database 1820752587</channel> <unit>BytesFile</unit> <value>1072545885175</value> </result> <result> <channel>DB-Size TestDB</channel> <unit>BytesFile</unit> <value>114756157440</value> </result> <result> <channel>Whitespace TestDB</channel> <unit>BytesFile</unit> <value>108396544</value> </result> <result> <channel>Size Index TestDB</channel> <unit>BytesFile</unit> <value>114933014528</value> </result> <result> <channel>DB-Size NewUsers</channel> <unit>BytesFile</unit> <value>259981312</value> </result> <result> <channel>Whitespace NewUsers</channel> <unit>BytesFile</unit> <value>110428160</value> </result> <result> <channel>Size Index NewUsers</channel> <unit>BytesFile</unit> <value>259981312</value> </result> </prtg> PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML>
What am i doing wrong?
Add comment