Exchange 2007 / 2010 Database Reporting Script


In a previous post (https://unlockpowershell.wordpress.com/2010/01/27/exchange-2007-mailbox-database-reporting-script/) I provided a script that we use to report on Our Exchange 2007 mailbox servers.

That post garnered a lot of comments because it didn’t work with mount points.

We now have a mix of Exchange 2007 and 2010, and I have updated my script – We also now use mount points, so I gather mount point data.

I have placed a copy of the script on the PowerShell Code Repository as well.

(Modified Script 7/28/2010)

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#.SYNOPSIS
# Get-ExchangeDBSizes – Gather data on Exchange 2007 / 2010 Mailbox Databases.
#.DESCRIPTION
# Gathers data from Exchange mailbox servers.
# These data include:
# Server\StorageGroup\Database (2007) or Database (2010),
# Total Size (in GB) of the disk,
# Size of the .edb file (in GB),
# Free disk space,
# Percent Disk Free,
# Total Mailboxes on the database,
# White Space,
# Total Free disk space,
# Total Percent Free disk space
#.EXAMPLE
# Get-ExchangeDBSizes
#.LINK
# https://unlockpowershell.wordpress.com/
# http://poshcode.org/1902
#.NOTES
# File Name: Get-ExchangeDBSizes.ps1
# Author: Karl Mitschke
# Requires: Exchange Managemnent Shell
# Requires: Powershell V2
# Created: 6/14/2010
# Modified: 7/28/2010 to convert .EdbFilePath to String
# Modified: 7/28/2010 – Changed whitespace to a [double]

Function Get-MountPointInfo($ServerName) { 
$Summary = @() 
$VolumeHash = @{}
$VolumeCapacityHash = @{}
$DatabaseSizeHash = @{}
$DatabaseFreeHash = @{}
$MountPoints = Get-WmiObject -Class Win32_Mountpoint -ComputerName $ServerName
$MailboxDatabases = Get-MailboxDatabase -Server $ServerName
$Volumes = Get-WmiObject -Class Win32_Volume -ComputerName $ServerName | Where-Object {$_.DriveType -eq 3}| Select-Object Name,FreeSpace,Capacity 
$DatabaseLetters = $MailboxDatabases | Select-Object edbfilepath
foreach ($Volume in $Volumes) {
$VolumeHash.Add($Volume.name.TrimEnd("\"),$Volume.FreeSpace)
$VolumeCapacityHash.Add($Volume.name.TrimEnd("\"),$Volume.Capacity)
}
foreach ($drive in $DatabaseLetters)
{
$letter = $drive.EdbFilePath.ToString().Substring(0,$drive.EdbFilePath.ToString().LastIndexOf("\"))
$DatabaseSizeHash.Add($letter.TrimEnd("\"),$VolumeCapacityHash[$letter])
$DatabaseFreeHash.Add($letter.TrimEnd("\"),$VolumeHash[$letter])
}
$VolumeHash.Clear()
$VolumeCapacityHash.Clear()
#Now I have all mailbox databases, along with the OS reported free space and capacity
foreach ($MP in $Mountpoints) { 
$MP.directory = $MP.directory.replace("\\","\").Split("=")[1].Replace("`"","") 
if($DatabaseSizeHash[$MP.directory])
{
#This mountpoint is a database
$Record = new-Object PSObject
$OSfree = $DatabaseFreeHash[$MP.directory]
$OSCapacity = $DatabaseSizeHash[$MP.directory]
$DestFolder = "\\"+$ServerName + "\" + $MP.directory
$colItems = (Get-ChildItem $destfolder.Replace(":","$") -Recurse| where{$_.length -ne $null} |Measure-Object -property length -sum) 
if($colItems.sum -eq $null) { 
$fsize = 0 
} else { 
$fsize = $colItems.sum 
} 
$TotFolderSize = $fsize + $OSfree 
$percFree = "{0:P0}" -f ( $OSfree/$TotFolderSize) 
$Record | add-Member -memberType noteProperty -name Server -Value $ServerName 
$Record | add-Member -memberType noteProperty -name "Mount Point" -Value $MP.directory
$Record | add-Member -memberType noteProperty -name "Capacity" -Value ("{0:N2}" -f ($OSCapacity /1gb))
$Record | add-Member -memberType noteProperty -name "Used" -Value ("{0:N2}" -f ($fsize / 1gb)) 
$Record | add-Member -memberType noteProperty -name "Free" -Value ("{0:N2}" -f ($OSfree / 1gb)) 
$Record | add-Member -memberType noteProperty -name "Percent Free" -Value $percFree 
$Summary += $Record 
} 
} 
return $Summary 
} 
function Get-ExchangeWhiteSpace { 
param( 
   $ComputerName = $(throw "ComputerName cannot be empty.") 
)

# Convert Dates to WMI CIM dates
$tc = [System.Management.ManagementDateTimeconverter] 
$Start =$tc::ToDmtfDateTime( (Get-Date).AddDays(-1).Date ) 
$End =$tc::ToDmtfDateTime( (Get-Date).Date) 

$whiteSpace = @{}

# Create two claculated properties for InsertionStrings values
$DB = @{Name="DB";Expression={$_.InsertionStrings[1]}} 
$FreeMB = @{Name="FreeMB";Expression={[int]$_.InsertionStrings[0]}} 

$freespace = Get-WMIObject Win32_NTLogEvent -ComputerName $ComputerName -Filter "LogFile=’Application’ AND EventCode=1221 AND TimeWritten>=’$Start’ AND TimeWritten<=’$End’" | Select-Object $DB,$FreeMB | Sort-Object DB –Unique –Descending
$freespace | ForEach-Object {$whiteSpace.Add($_.DB,$_.FreeMB)}
#Preceding function from Shay Levy http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2009/08/13/exchange-white-space.aspx
}

$AllServers = @()
$ServerVersion = @{}
foreach ($server in Get-MailboxServer)
{
$ServerName = $server.name
$version = Get-ExchangeServer -Identity $ServerName | Select-Object AdminDisplayVersion
if($version.admindisplayversion.major)
{
$ServerVersion.Add($ServerName,$version.admindisplayversion.major)
}
else
{
$ServerVersion.Add($ServerName,$version.admindisplayversion.Split()[1].split(".")[0])
}
}
foreach ($server in Get-MailboxServer)
{
$ServerName = $server.Name
if ([int]$ServerVersion[$ServerName] -gt 8)
{ #An Exchange 2010 server, so use Get-MailboxDatabase <database> -Status | Select-Object AvailableNewMailboxSpace
$whiteSpace = @{}
$Free = Get-MailboxDatabase -Server $ServerName -Status | Select-Object Server,Name,AvailableNewMailboxSpace
foreach ($item in $free)
{
$db = $ServerName+"\"+$item.Name
$whiteSpace.Add($item.Name,[double]$item.AvailableNewMailboxSpace.split("(")[1].Split()[0]/1mb)
}
}
Else
{#not an Exchange 2010 server
. Get-ExchangeWhiteSpace $ServerName
}
$MountPoint = . Get-MountPointInfo $ServerName
foreach ($objItem in Get-MailboxDatabase -Server $ServerName)
    {
    $edbfilepath = $objItem.edbfilepath
    $path = "`\`\" + $ServerName + "`\" + $objItem.EdbFilePath.ToString().Split(":")[0] + "$"+ $objItem.EdbFilePath.ToString().Split(":")[1]
    $dbsize = Get-ChildItem $path
$dbpath=(Split-Path $EdbFilePath.ToString().Split(":")[1] -Leaf).trimend(".edb")
if (!$MountPoint)
{
$mailboxpath = $ServerName + $EdbFilePath.ToString().Split(":")[1].trimend(".edb")
$size = get-wmiobject -computername $ServerName win32_logicaldisk |where-object {$_.deviceid -eq $objItem.EdbFilePath.ToString().Split("\")[0]} |select-object deviceID, Freespace, Size
$freespace = ($size.freespace / 1GB)
$total = ($size.size / 1GB)
}
if ($MountPoint)
{
$mailboxpath = "$ServerName\$dbpath"
$MPPath = $EdbFilePath.ToString().Substring(0,$EdbFilePath.ToString().LastIndexOf("\"))
$freespace = $DatabaseFreeHash[$MPPath ] /1GB
$total = $DatabaseSizeHash[$MPPath] /1GB
}
$PercentFree = "{0:n2}" -f ($freespace / $total *100)
if (!$MountPoint)
{
$mailboxcount = Get-MailboxStatistics -database "$mailboxpath"  |Where {$_.DisconnectDate -eq $null -and $_.ObjectClass -eq ‘Mailbox’} |measure-object
}
if($MountPoint)
{
$mailboxcount = Get-MailboxStatistics -database $mailboxpath.Split("\")[1]  |Where {$_.DisconnectDate -eq $null -and $_.ObjectClass -eq ‘Mailbox’} |measure-object
}

$ReturnedObj = New-Object PSObject
$ReturnedObj | Add-Member -MemberType NoteProperty -Name "Server\StorageGroup\Database" -Value $objItem.Identity
$ReturnedObj | Add-Member -MemberType NoteProperty -Name "Total Size (GB)" -Value ("{0:n2}" -f ($total))
$ReturnedObj | Add-Member -MemberType NoteProperty -Name "Used Space (GB)" -Value ("{0:n2}" -f ($dbsize.Length/1024MB))
$ReturnedObj | Add-Member -MemberType NoteProperty -Name "Free Space (GB)" -Value ("{0:n2}" -f ($freespace))
$ReturnedObj | Add-Member -MemberType NoteProperty -Name "Percent Disk Free" -Value $percentfree
$ReturnedObj | Add-Member -MemberType NoteProperty -Name "User Mailbox Count" -Value $mailboxcount.count
if ($objitem.Identity.Split("\").Count -eq 3){$dbasename = $objitem.Identity.Substring($objitem.Identity.IndexOf("\")+1)}
else{$dbasename = $objitem.Identity}
$ReturnedObj | Add-Member -MemberType NoteProperty -Name "White Space (GB)" -Value ("{0:n2}" -f ($whiteSpace[$dbasename]/1024))
$ReturnedObj | Add-Member -MemberType NoteProperty -Name "Total Free (GB)" -Value ("{0:n2}" -f ($freespace + $whiteSpace[$dbasename]/1024))
$TotalPercent = ($freespace + $whiteSpace[$dbasename]/1024) / $total *100
$ReturnedObj | Add-Member -MemberType NoteProperty -Name "Total Percent Free" -Value ("{0:n2}" -f ($TotalPercent))
    $AllServers += $ReturnedObj
}
}
$AllServers |Export-Csv C:\scripts\MailboxDatabaseSizeReport.csv -NoTypeInformation

Advertisements
  1. #1 by Kloecker on July 21, 2010 - 16:16

    Hello,

    i get following error and the script stopped.
    —-
    Method invocation failed because [Microsoft.Exchange.Data.EdbFilePath] doesn’t contain a method named ‘lastIndexOf’.
    An :Zeile:40 Zeichen:72
    + $letter = $drive.EdbFilePath.Substring(0,$drive.EdbFilePath.lastIndexOf <<<< ("\"))

    i don't know, where the problem is.

    • #2 by karlmitschke on July 26, 2010 - 14:28

      Hello;

      Try changing line 40 as follows:
      $letter = $drive.EdbFilePath.Substring(0,$drive.EdbFilePath.ToString().LastIndexOf(“\”))

      Karl

  2. #3 by Kloecker on July 27, 2010 - 08:38

    Sorry,
    but now i got following error.
    Method invocation failed because [Microsoft.Exchange.Data.EdbFilePath] doesn’t contain a method named ‘Substring’.
    An :Zeile:40 Zeichen:38
    + $letter = $drive.EdbFilePath.Substring <<<< (0,$drive.EdbFilePath.ToString().LastIndexOf(“\”))
    Ansgar
    I run the script against an Windows 2008 SP2 Server with Exchange2007 SP2

  3. #4 by karlmitschke on July 27, 2010 - 15:31

    Hello;

    Sorry about that.

    Try this:

    $letter = $drive.EdbFilePath.ToString().Substring(0,$drive.EdbFilePath.ToString().LastIndexOf(“\”))

  4. #5 by Kloecker on July 28, 2010 - 07:55

    Hello,
    next error:
    Method invocation failed because [Microsoft.Exchange.Data.EdbFilePath] doesn’t contain a method named ‘Split’.
    An :Zeile:135 Zeichen:69
    + $path = “`\`\” + $ServerName + “`\” + $objItem.EdbFilePath.Split <<<< (":")[0] + "$"+ $objItem.EdbFilePath.Split(":")[1]

  5. #6 by Urlryn on July 28, 2010 - 11:59

    Ok Karl….i’m here now! 🙂

    Sorry for the initial confusion! looks like someone else is having some of the same issues as I am.

    Urlryn

  6. #7 by karlmitschke on July 28, 2010 - 15:15

    I have modified the script – please try it now.

    Karl

  7. #8 by Luke on July 28, 2010 - 17:47

    Hi,

    Nice script but it would be nice to pass a server name into the script as a parameter. Within our organisation not all teams have access to all mailbox servers, so this script fails with an access denied as it tries to connect to mailbox servers not managed within our group.

    • #9 by karlmitschke on August 2, 2010 - 20:21

      Luke;
      I was actually planning to do that – stay tuned, and I hope to have it this week.
      Karl

  8. #10 by zach on July 28, 2010 - 18:31

    Im dont think I am executing this script properly. I am attempting to run this against Exchange 2010 (2 copy/4 node dag). I have the script PS1 saved to the server but when I run it i get a screen full of errors.

    I am running it like this: .\get-exchangedbsizes.ps1 and/or .\get-exchangedbsizes -servername

    First error is:

    Method invocation failed because [Microsoft.Exchange.Data.ByteQuantifiedSize] doesn’t contain a method named ‘split’.
    At C:\Software\get-exchangedbsizes.ps1:120 char:72

    • #11 by karlmitschke on August 2, 2010 - 20:26

      Zach;
      Can you tell me the rest of error 1?
      Method invocation failed because [Microsoft.Exchange.Data.ByteQuantifiedSize] doesn’t contain a method named ‘split’.
      At C:\Software\get-exchangedbsizes.ps1:120 char:72

      Or, better yet, tell me what line 120 is in your script?

      Karl

      • #12 by Luke on August 2, 2010 - 22:57

        The split error is due to running the script in version 1 of Powershell. Split was introduced in version 2

      • #13 by zach on August 2, 2010 - 23:03

        Running this on 2008 R2 and I verified Powershell 2.0

        Line 120 of the script is:

        $whiteSpace.Add($item.Name,[double]$item.AvailableNewMailboxSpace.split(“(“)[1].Split()[0]/1mb)

        Here is some more of the error. First three parts. I could capture the whole output and post it to a text file somewhere.

        Method invocation failed because [Microsoft.Exchange.Data.ByteQuantifiedSize] doesn’t contain a method named ‘split’.
        At C:\software\get-exchangedbsizes.ps1:120 char:72
        + $whiteSpace.Add($item.Name,[double]$item.AvailableNewMailboxSpace.split <<<< ("(")[1].Split()[0]/1mb)
        + CategoryInfo : InvalidOperation: (split:String) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound

        Method invocation failed because [Microsoft.Exchange.Data.ByteQuantifiedSize] doesn't contain a method named 'split'.
        At C:\software\get-exchangedbsizes.ps1:120 char:72
        + $whiteSpace.Add($item.Name,[double]$item.AvailableNewMailboxSpace.split <<<< ("(")[1].Split()[0]/1mb)
        + CategoryInfo : InvalidOperation: (split:String) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound

        Method invocation failed because [Microsoft.Exchange.Data.ByteQuantifiedSize] doesn't contain a method named 'split'.
        At C:\software\get-exchangedbsizes.ps1:120 char:72
        + $whiteSpace.Add($item.Name,[double]$item.AvailableNewMailboxSpace.split <<<< ("(")[1].Split()[0]/1mb)
        + CategoryInfo : InvalidOperation: (split:String) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound

        Am i suppose to pass a server name to the script? I notice someone else just commented about that which makes me think no…

      • #14 by karlmitschke on August 31, 2010 - 00:53

        Zach;
        Sorry I have been absent for so long – are you running PowerShell v1 or v2?
        Karl

  9. #15 by Urlryn on July 29, 2010 - 12:24

    Morning Karl!

    Here is the latest error on the script! Is the reason for this issue cause of powerscript v2?

    Get-WmiObject : Invalid query
    At C:\db_report3.ps1:96 char:27
    + $freespace = Get-WMIObject <<<=’$Start’ AN
    D TimeWritten<='$End'" | Select-Object $DB,$FreeMB | Sort-Object DB -Unique -De
    scending
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], Managemen
    tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
    ommands.GetWmiObjectCommand

    Exception calling "Add" with "2" argument(s): "Key cannot be null.
    Parameter name: key"
    At C:\db_report3.ps1:97 char:45
    + $freespace | ForEach-Object {$whiteSpace.Add <<<< ($_.DB,$_.FreeMB)}
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

  10. #16 by Kloecker on August 3, 2010 - 17:32

    Hello Karl,
    the next problem is, that the function mountpoint cannot recognize, that the db’s are on mountpoints
    $MountPoint = . Get-MountPointInfo $ServerName

    The result ist false, but all db’s on the server are on mountpoints.

  11. #17 by karlmitschke on August 4, 2010 - 21:33

    Hello;

    What happens if you run this in a seperate powershell window?
    Get-WmiObject -Class Win32_Mountpoint -ComputerName
    Get-WmiObject -Class Win32_Volume -ComputerName | Where-Object {$_.DriveType -eq 3}

  12. #18 by Urlryn on January 19, 2011 - 13:14

    Hey Karl!

    Man its been a long time since i needed this! So many other projects!

    But wanted to finally comment that both those commands worked for me.
    Ran them both on Windows Server 2008 R2, Windows Server 2008, Windows 7 Enterprise.
    Ran them against 7 different 2007/2010 exchange servers and all is good with that.

  13. #19 by albertwt on February 24, 2011 - 17:03

    Many thakns again for posting such a good script, however, do I need to run this script on my laptop w/ Exc 2k7 Mgmt Console or i need to run this on my server ?

  14. #21 by andy on March 1, 2011 - 13:03

    on what line do i modify to specify my server name to pass as a parameter?

    • #22 by Karl Mitschke on March 1, 2011 - 19:13

      Line 103 “foreach ($server in Get-MailboxServer)” will retrive all of your mailbox servers.

      You could modify it to foreach ($server in Get-MailboxServer )

      Karl

  15. #23 by David on March 7, 2011 - 14:01

    Backround

    Single Exchange server with netapp attached storage.

    This looks like a great script. I can’t seem to get to work for me. Here are the errors when I run it:

    Exception calling “Add” with “2” argument(s): “Key cannot be null.
    Parameter name: key”
    At C:\Scripts\Get-ExchangeDBSizes.ps1:100 char:45
    + $freespace | ForEach-Object {$whiteSpace.Add <<<< ($_.DB,$_.FreeMB)}
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    Get-ChildItem : Cannot find path '\\STRSEXCH1\M$\Program Files\Microsoft\Exchange Server\Mailbox\First Storage Group\Mai
    lbox Database.edb' because it does not exist.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:141 char:28
    + $dbsize = Get-ChildItem <<<< $path
    + CategoryInfo : ObjectNotFound: (\\STRSEXCH1\M$\…ox Database.edb:String) [Get-ChildItem], ItemNotFoundE
    xception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

    Get-MailboxStatistics : Cannot bind parameter 'Database'. Cannot convert value "STRSEXCH1\Program Files\Microsoft\Exchan
    ge Server\Mailbox\First Storage Group\Mailbox Databas" to type "Microsoft.Exchange.Configuration.Tasks.DatabaseIdParamet
    er". Error: "'STRSEXCH1\Program Files\Microsoft\Exchange Server\Mailbox\First Storage Group\Mailbox Databas' is not a va
    lid value for the identity.
    Parameter name: Identity"
    At C:\Scripts\Get-ExchangeDBSizes.ps1:160 char:50
    + $mailboxcount = Get-MailboxStatistics -database <<<< "$mailboxpath" |Where {$_.DisconnectDate -eq $null -and
    $_.ObjectClass -eq 'Mailbox'} |measure-object
    + CategoryInfo : InvalidArgument: (:) [Get-MailboxStatistics], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.MapiTasks.GetMailboxStatisti
    cs

    Method invocation failed because [Microsoft.Exchange.Data.Directory.ADObjectId] doesn't contain a method named 'Split'.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:174 char:29
    + if ($objitem.Identity.Split <<<< ("\").Count -eq 3){$dbasename = $objitem.Identity.Substring($objitem.Identity.Ind
    exOf("\")+1)}
    + CategoryInfo : InvalidOperation: (Split:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:176 char:111
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "White Space (GB)" -Value ("{0:n2}" -f ($whiteSpace[ <<<<
    $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:177 char:123
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "Total Free (GB)" -Value ("{0:n2}" -f ($freespace + $whit
    eSpace[ <<<< $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:178 char:44
    + $TotalPercent = ($freespace + $whiteSpace[ <<<< $dbasename]/1024) / $total *100
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Get-ChildItem : Cannot find path '\\STRSEXCH1\N$\Program Files\Microsoft\Exchange Server\Mailbox\Third Storage Group\Mai
    lbox Database.edb' because it does not exist.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:141 char:28
    + $dbsize = Get-ChildItem <<<< $path
    + CategoryInfo : ObjectNotFound: (\\STRSEXCH1\N$\…ox Database.edb:String) [Get-ChildItem], ItemNotFoundE
    xception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

    Get-MailboxStatistics : Cannot bind parameter 'Database'. Cannot convert value "STRSEXCH1\Program Files\Microsoft\Exchan
    ge Server\Mailbox\Third Storage Group\Mailbox Databas" to type "Microsoft.Exchange.Configuration.Tasks.DatabaseIdParamet
    er". Error: "'STRSEXCH1\Program Files\Microsoft\Exchange Server\Mailbox\Third Storage Group\Mailbox Databas' is not a va
    lid value for the identity.
    Parameter name: Identity"
    At C:\Scripts\Get-ExchangeDBSizes.ps1:160 char:50
    + $mailboxcount = Get-MailboxStatistics -database <<<< "$mailboxpath" |Where {$_.DisconnectDate -eq $null -and
    $_.ObjectClass -eq 'Mailbox'} |measure-object
    + CategoryInfo : InvalidArgument: (:) [Get-MailboxStatistics], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.MapiTasks.GetMailboxStatisti
    cs

    Method invocation failed because [Microsoft.Exchange.Data.Directory.ADObjectId] doesn't contain a method named 'Split'.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:174 char:29
    + if ($objitem.Identity.Split <<<< ("\").Count -eq 3){$dbasename = $objitem.Identity.Substring($objitem.Identity.Ind
    exOf("\")+1)}
    + CategoryInfo : InvalidOperation: (Split:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:176 char:111
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "White Space (GB)" -Value ("{0:n2}" -f ($whiteSpace[ <<<<
    $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:177 char:123
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "Total Free (GB)" -Value ("{0:n2}" -f ($freespace + $whit
    eSpace[ <<<< $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:178 char:44
    + $TotalPercent = ($freespace + $whiteSpace[ <<<< $dbasename]/1024) / $total *100
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Get-ChildItem : Cannot find path '\\STRSEXCH1\O$\Program Files\Microsoft\Exchange Server\Mailbox\Fourth Storage Group\Ma
    ilbox Database.edb' because it does not exist.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:141 char:28
    + $dbsize = Get-ChildItem <<<< $path
    + CategoryInfo : ObjectNotFound: (\\STRSEXCH1\O$\…ox Database.edb:String) [Get-ChildItem], ItemNotFoundE
    xception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

    Get-MailboxStatistics : Cannot bind parameter 'Database'. Cannot convert value "STRSEXCH1\Program Files\Microsoft\Exchan
    ge Server\Mailbox\Fourth Storage Group\Mailbox Databas" to type "Microsoft.Exchange.Configuration.Tasks.DatabaseIdParame
    ter". Error: "'STRSEXCH1\Program Files\Microsoft\Exchange Server\Mailbox\Fourth Storage Group\Mailbox Databas' is not a
    valid value for the identity.
    Parameter name: Identity"
    At C:\Scripts\Get-ExchangeDBSizes.ps1:160 char:50
    + $mailboxcount = Get-MailboxStatistics -database <<<< "$mailboxpath" |Where {$_.DisconnectDate -eq $null -and
    $_.ObjectClass -eq 'Mailbox'} |measure-object
    + CategoryInfo : InvalidArgument: (:) [Get-MailboxStatistics], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.MapiTasks.GetMailboxStatisti
    cs

    Method invocation failed because [Microsoft.Exchange.Data.Directory.ADObjectId] doesn't contain a method named 'Split'.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:174 char:29
    + if ($objitem.Identity.Split <<<< ("\").Count -eq 3){$dbasename = $objitem.Identity.Substring($objitem.Identity.Ind
    exOf("\")+1)}
    + CategoryInfo : InvalidOperation: (Split:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:176 char:111
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "White Space (GB)" -Value ("{0:n2}" -f ($whiteSpace[ <<<<
    $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:177 char:123
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "Total Free (GB)" -Value ("{0:n2}" -f ($freespace + $whit
    eSpace[ <<<< $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:178 char:44
    + $TotalPercent = ($freespace + $whiteSpace[ <<<< $dbasename]/1024) / $total *100
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Get-ChildItem : Cannot find path '\\STRSEXCH1\Q$\Program Files\Microsoft\Exchange Server\Mailbox\Fifth Storage Group\Mai
    lbox Database.edb' because it does not exist.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:141 char:28
    + $dbsize = Get-ChildItem <<<< $path
    + CategoryInfo : ObjectNotFound: (\\STRSEXCH1\Q$\…ox Database.edb:String) [Get-ChildItem], ItemNotFoundE
    xception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

    Get-MailboxStatistics : Cannot bind parameter 'Database'. Cannot convert value "STRSEXCH1\Program Files\Microsoft\Exchan
    ge Server\Mailbox\Fifth Storage Group\Mailbox Databas" to type "Microsoft.Exchange.Configuration.Tasks.DatabaseIdParamet
    er". Error: "'STRSEXCH1\Program Files\Microsoft\Exchange Server\Mailbox\Fifth Storage Group\Mailbox Databas' is not a va
    lid value for the identity.
    Parameter name: Identity"
    At C:\Scripts\Get-ExchangeDBSizes.ps1:160 char:50
    + $mailboxcount = Get-MailboxStatistics -database <<<< "$mailboxpath" |Where {$_.DisconnectDate -eq $null -and
    $_.ObjectClass -eq 'Mailbox'} |measure-object
    + CategoryInfo : InvalidArgument: (:) [Get-MailboxStatistics], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.MapiTasks.GetMailboxStatisti
    cs

    Method invocation failed because [Microsoft.Exchange.Data.Directory.ADObjectId] doesn't contain a method named 'Split'.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:174 char:29
    + if ($objitem.Identity.Split <<<< ("\").Count -eq 3){$dbasename = $objitem.Identity.Substring($objitem.Identity.Ind
    exOf("\")+1)}
    + CategoryInfo : InvalidOperation: (Split:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:176 char:111
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "White Space (GB)" -Value ("{0:n2}" -f ($whiteSpace[ <<<<
    $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:177 char:123
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "Total Free (GB)" -Value ("{0:n2}" -f ($freespace + $whit
    eSpace[ <<<< $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:178 char:44
    + $TotalPercent = ($freespace + $whiteSpace[ <<<< $dbasename]/1024) / $total *100
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Get-ChildItem : Cannot find path '\\STRSEXCH1\R$\Program Files\Microsoft\Exchange Server\Mailbox\Sixth Storage Group\Mai
    lbox Database.edb' because it does not exist.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:141 char:28
    + $dbsize = Get-ChildItem <<<< $path
    + CategoryInfo : ObjectNotFound: (\\STRSEXCH1\R$\…ox Database.edb:String) [Get-ChildItem], ItemNotFoundE
    xception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

    Get-MailboxStatistics : Cannot bind parameter 'Database'. Cannot convert value "STRSEXCH1\Program Files\Microsoft\Exchan
    ge Server\Mailbox\Sixth Storage Group\Mailbox Databas" to type "Microsoft.Exchange.Configuration.Tasks.DatabaseIdParamet
    er". Error: "'STRSEXCH1\Program Files\Microsoft\Exchange Server\Mailbox\Sixth Storage Group\Mailbox Databas' is not a va
    lid value for the identity.
    Parameter name: Identity"
    At C:\Scripts\Get-ExchangeDBSizes.ps1:160 char:50
    + $mailboxcount = Get-MailboxStatistics -database <<<< "$mailboxpath" |Where {$_.DisconnectDate -eq $null -and
    $_.ObjectClass -eq 'Mailbox'} |measure-object
    + CategoryInfo : InvalidArgument: (:) [Get-MailboxStatistics], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.MapiTasks.GetMailboxStatisti
    cs

    Method invocation failed because [Microsoft.Exchange.Data.Directory.ADObjectId] doesn't contain a method named 'Split'.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:174 char:29
    + if ($objitem.Identity.Split <<<< ("\").Count -eq 3){$dbasename = $objitem.Identity.Substring($objitem.Identity.Ind
    exOf("\")+1)}
    + CategoryInfo : InvalidOperation: (Split:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:176 char:111
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "White Space (GB)" -Value ("{0:n2}" -f ($whiteSpace[ <<<<
    $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:177 char:123
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "Total Free (GB)" -Value ("{0:n2}" -f ($freespace + $whit
    eSpace[ <<<< $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:178 char:44
    + $TotalPercent = ($freespace + $whiteSpace[ <<<< $dbasename]/1024) / $total *100
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Get-ChildItem : Cannot find path '\\STRSEXCH1\S$\Program Files\Microsoft\Exchange Server\Mailbox\Seventh Storage Group\M
    ailbox Database.edb' because it does not exist.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:141 char:28
    + $dbsize = Get-ChildItem <<<< $path
    + CategoryInfo : ObjectNotFound: (\\STRSEXCH1\S$\…ox Database.edb:String) [Get-ChildItem], ItemNotFoundE
    xception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

    Get-MailboxStatistics : Cannot bind parameter 'Database'. Cannot convert value "STRSEXCH1\Program Files\Microsoft\Exchan
    ge Server\Mailbox\Seventh Storage Group\Mailbox Databas" to type "Microsoft.Exchange.Configuration.Tasks.DatabaseIdParam
    eter". Error: "'STRSEXCH1\Program Files\Microsoft\Exchange Server\Mailbox\Seventh Storage Group\Mailbox Databas' is not
    a valid value for the identity.
    Parameter name: Identity"
    At C:\Scripts\Get-ExchangeDBSizes.ps1:160 char:50
    + $mailboxcount = Get-MailboxStatistics -database <<<< "$mailboxpath" |Where {$_.DisconnectDate -eq $null -and
    $_.ObjectClass -eq 'Mailbox'} |measure-object
    + CategoryInfo : InvalidArgument: (:) [Get-MailboxStatistics], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.MapiTasks.GetMailboxStatisti
    cs

    Method invocation failed because [Microsoft.Exchange.Data.Directory.ADObjectId] doesn't contain a method named 'Split'.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:174 char:29
    + if ($objitem.Identity.Split <<<< ("\").Count -eq 3){$dbasename = $objitem.Identity.Substring($objitem.Identity.Ind
    exOf("\")+1)}
    + CategoryInfo : InvalidOperation: (Split:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:176 char:111
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "White Space (GB)" -Value ("{0:n2}" -f ($whiteSpace[ <<<<
    $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:177 char:123
    + $ReturnedObj | Add-Member -MemberType NoteProperty -Name "Total Free (GB)" -Value ("{0:n2}" -f ($freespace + $whit
    eSpace[ <<<< $dbasename]/1024))
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At C:\Scripts\Get-ExchangeDBSizes.ps1:178 char:44
    + $TotalPercent = ($freespace + $whiteSpace[ <<<< $dbasename]/1024) / $total *100
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

    I figure it has somthing to do with the path but when I run Get-Mailboxserver -Identity strsexch1 |Get-MailboxDatabase |fl edbfilepath I get:

    EdbFilePath : M:\Program Files\Microsoft\Exchange Server\Mailbox\First Storage
    Group\Mailbox Database.edb

    EdbFilePath : N:\Program Files\Microsoft\Exchange Server\Mailbox\Third Storage
    Group\Mailbox Database.edb

    EdbFilePath : O:\Program Files\Microsoft\Exchange Server\Mailbox\Fourth Storage
    Group\Mailbox Database.edb

    EdbFilePath : Q:\Program Files\Microsoft\Exchange Server\Mailbox\Fifth Storage
    Group\Mailbox Database.edb

    EdbFilePath : R:\Program Files\Microsoft\Exchange Server\Mailbox\Sixth Storage
    Group\Mailbox Database.edb

    EdbFilePath : S:\Program Files\Microsoft\Exchange Server\Mailbox\Seventh Storag
    e Group\Mailbox Database.edb

    Thanks,

    David

  16. #24 by David on March 24, 2011 - 13:15

    nevermind I was able to tweak the script to get it to work for my server. Thanks.

    • #25 by JU on April 21, 2011 - 07:22

      hi David, would you mind posting your tweaked scripts please 🙂

  17. #26 by Albert on August 23, 2011 - 08:51

    Hi,

    is this script working for the Exchange Server 2007 CCR mode ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: