Albert Widjaja
asked on
Modifying PowerShell script to show total transaction log size in Exchange Server 2013 ?
I had this question after viewing Powershell to show mailbox DB .EDB size ?.
Hi,
Can anyone here please assist me in modifying the below PowerShell script to calculate the Exchange Transaction log file size ?
So far it works great, but I cannot get the total Transaction Log size.
Any help would be greatly appreciated.
Thanks,
Hi,
Can anyone here please assist me in modifying the below PowerShell script to calculate the Exchange Transaction log file size ?
Get-MailboxDatabase |
Select Server,
Name,
@{Name="DB Size (GB)";Expression={$objitem = (Get-MailboxDatabase $_.Identity); $path = "`\`\" + $objitem.server + "`\" + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + "$"+ $objItem.EdbFilePath.PathName.Remove(0,2); $size = ((Get-ChildItem $path).length)/1048576KB; [math]::round($size, 2)}},
@{Name="Number of Mbx";expression={(Get-Mailbox -Database $_.Identity | Measure-Object).Count}},
EdbFilePath,
LogFolderPath,
LogFileSize,
CircularLoggingEnabled,
IsPublicFolderDatabase | ft -AutoSize
So far it works great, but I cannot get the total Transaction Log size.
Any help would be greatly appreciated.
Thanks,
ASKER
Hi Robin,
My Exchange mailbox DB and the Transaction logs are in the same folder due to DAG limitations.
My Exchange mailbox DB and the Transaction logs are in the same folder due to DAG limitations.
No Problem,
I have amended the 2 sums for Database Size and Log Folder Size to exclude the logs and the database respectively,
Log Size GB:
Log Size KB:
Thanks
Robin
I have amended the 2 sums for Database Size and Log Folder Size to exclude the logs and the database respectively,
Log Size GB:
Get-MailboxDatabase |
Select Server,
Name,
@{Name="DB Size (GB)";Expression={$objitem = (Get-MailboxDatabase $_.Identity); $databasepath = "`\`\" + $objitem.server + "`\" + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + "$"+ $objItem.EdbFilePath.PathName.Remove(0,2); $databasesize = ((Get-ChildItem $databasepath).length)/1048576KB; [math]::round($databasesize, 2)}},
@{Name="Number of Mbx";expression={(Get-Mailbox -Database $_.Identity | Measure-Object).Count}},
EdbFilePath,
LogFolderPath,
@{Name="Log Folder Size (GB)";Expression={$objitem = (Get-MailboxDatabase $_.Identity); $logpath = "`\`\" + $objitem.server + "`\" + $objItem.LogFolderPath.DriveName.Remove(1).ToString() + "$"+ $objItem.LogFolderPath.PathName.Remove(0,2); $logsize = ((Get-ChildItem $logpath -exclude "*edb*,*CatalogData*").length)/1048576KB; [math]::round($logsize, 2)}},
IsPublicFolderDatabase | ft -AutoSize
Log Size MB:
Get-MailboxDatabase |
Select Server,
Name,
@{Name="DB Size (GB)";Expression={$objitem = (Get-MailboxDatabase $_.Identity); $databasepath = "`\`\" + $objitem.server + "`\" + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + "$"+ $objItem.EdbFilePath.PathName.Remove(0,2); $databasesize = ((Get-ChildItem $databasepath).length)/1048576KB; [math]::round($databasesize, 2)}},
@{Name="Number of Mbx";expression={(Get-Mailbox -Database $_.Identity | Measure-Object).Count}},
EdbFilePath,
LogFolderPath,
@{Name="Log Folder Size (MB)";Expression={$objitem = (Get-MailboxDatabase $_.Identity); $logpath = "`\`\" + $objitem.server + "`\" + $objItem.LogFolderPath.DriveName.Remove(1).ToString() + "$"+ $objItem.LogFolderPath.PathName.Remove(0,2); $logsize = ((Get-ChildItem $logpath -exclude "*edb*,*CatalogData*").length)/1024KB; [math]::round($logsize, 2)}},
IsPublicFolderDatabase | ft -AutoSize
Log Size KB:
Get-MailboxDatabase |
Select Server,
Name,
@{Name="DB Size (GB)";Expression={$objitem = (Get-MailboxDatabase $_.Identity); $databasepath = "`\`\" + $objitem.server + "`\" + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + "$"+ $objItem.EdbFilePath.PathName.Remove(0,2); $databasesize = ((Get-ChildItem $databasepath).length)/1048576KB; [math]::round($databasesize, 2)}},
@{Name="Number of Mbx";expression={(Get-Mailbox -Database $_.Identity | Measure-Object).Count}},
EdbFilePath,
LogFolderPath,
@{Name="Log Folder Size (KB)";Expression={$objitem = (Get-MailboxDatabase $_.Identity); $logpath = "`\`\" + $objitem.server + "`\" + $objItem.LogFolderPath.DriveName.Remove(1).ToString() + "$"+ $objItem.LogFolderPath.PathName.Remove(0,2); $logsize = ((Get-ChildItem $logpath -exclude "*edb*,*CatalogData*").length)/1KB; [math]::round($logsize, 2)}},
IsPublicFolderDatabase | ft -AutoSize
Thanks
Robin
Hang on sorry, I noticed a slight mistake,
here it is resolved in MB:
Thanks
Robin
here it is resolved in MB:
Get-MailboxDatabase |
Select Server,
Name,
@{Name="DB Size (GB)";Expression={$objitem = (Get-MailboxDatabase $_.Identity); $databasepath = "`\`\" + $objitem.server + "`\" + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + "$"+ $objItem.EdbFilePath.PathName.Remove(0,2); $databasesize = ((Get-ChildItem $databasepath).length)/1048576KB; [math]::round($databasesize, 2)}},
@{Name="Number of Mbx";expression={(Get-Mailbox -Database $_.Identity | Measure-Object).Count}},
EdbFilePath,
LogFolderPath,
@{Name="Log Folder Size (MB)";Expression={$objitem = (Get-MailboxDatabase $_.Identity); $logpath = "`\`\" + $objitem.server + "`\" + $objItem.LogFolderPath.DriveName.Remove(1).ToString() + "$"+ $objItem.LogFolderPath.PathName.Remove(0,2) + "\*"; $logsize = ((Get-ChildItem $logpath -include "*log").length)/1024KB; [math]::round($logsize, 2)}},
IsPublicFolderDatabase | ft -AutoSize
Thanks
Robin
ASKER
Hi Robin,
THanks for the script.
Somehow the return is still 0 KB ?
The Exchange log filter that you proposed: -exclude "*edb*,*CatalogData*" looks makes more sense, but why are you replacing it into -include "*log" ?
THanks for the script.
Get-MailboxDatabase |
Select Server,
Name,
@{Name="DB Size (GB)";Expression={$objitem = (Get-MailboxDatabase $_.Identity); $databasepath = "`\`\" + $objitem.server + "`\" + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + "$"+ $objItem.EdbFilePath.PathName.Remove(0,2); $databasesize = ((Get-ChildItem $databasepath).length)/1048576KB; [math]::round($databasesize, 2)}},
@{Name="Number of Mbx";expression={(Get-Mailbox -Database $_.Identity | Measure-Object).Count}},
EdbFilePath,
LogFolderPath,
@{Name="Log Folder Size (MB)";Expression={$objitem = (Get-MailboxDatabase $_.Identity); $logpath = "`\`\" + $objitem.server + "`\" + $objItem.LogFolderPath.DriveName.Remove(1).ToString() + "$"+ $objItem.LogFolderPath.PathName.Remove(0,2) + "\*"; $logsize = ((Get-ChildItem $logpath -include "*log").length)/1024KB; [math]::round($logsize, 2)}},
IsPublicFolderDatabase | ft -AutoSize
Somehow the return is still 0 KB ?
The Exchange log filter that you proposed: -exclude "*edb*,*CatalogData*" looks makes more sense, but why are you replacing it into -include "*log" ?
ASKER
Exchange Server logs is a 1 MB text file starts with E0*.log extension.
I've changed it into: Get-ChildItem $logpath -include "*.log" and even Exclude "*edb*,*CatalogData*" -include "*.log" but still not working either ?
it shows 0 on the column
I've changed it into: Get-ChildItem $logpath -include "*.log" and even Exclude "*edb*,*CatalogData*" -include "*.log" but still not working either ?
it shows 0 on the column
When you look at the log location do you see many logs in there? Is the database size working?
ASKER
Yes, there are hundreds of E00*.log files and also the database size is working with no issue.
As soon as I'm in front of a pc, I will amended it slightly and send it back on a slight variation
ASKER
Sure Robin,
Many thanks for the assistance !
Many thanks for the assistance !
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Robin, it works great
The problem you have is it is the folder size that you are really looking for not the file size (as Exchange builds lots of them at the maximum file size which is the Log File Size,
here is one that will show it to you in MB
Open in new window
and here it is modified to show you it in GBOpen in new window
Thanks
Robin