This script compares the existing mounted volumes on a server with the existing databases. It returns the volume names for each of them that don't have a match.
<# .SYNOPSIS Compare Mountpoints on server to actual databases. .DESCRIPTION Provides details on mountpoints that could potentially be deleted because they're not being used. .PARAMETER Servername Name of Exchange Mailbox server to run against. .EXAMPLE#> [CmdLetBinding()] param( [parameter(Mandatory=$true)] [string]$ServerName ) function Get-MountPointInfo { [CmdLetBinding()] param( [parameter(Mandatory=$true)] [string]$ServerName ) #returns mount points that have matching volumes. $MountPoints = gwmi -class "win32_mountpoint" -namespace "root\cimv2" -computername $ServerName | select @{Name="Name";expression={$_.directory.split('"')[1].replace("\\","\")}} $Volumes = gwmi -class "win32_volume" -namespace "root/cimv2" -ComputerName $ServerName| select @{Name="name";Expression={$_.name.Substring(0,$_.name.length-1 )}}, freespace ,Capacity $summary = Compare-Object $Mountpoints $Volumes -IncludeEqual -Property Name | ?{$_.sideindicator -eq "=="} | select name return $summary } $dbs = get-mailboxdatabase -server $ServerName $mps = get-mountpointinfo -servername $ServerName | sort name $Index = 0 ForEach ($mp in $mps) { $found = ($dbs | ?{$_.logfolderpath.tostring() -like $mp.name}) -ne $null if (!$found) { if ($Index -eq 0) {Write-Host "Mount points that don't have matching DBs"} Write-Host "!Found:"$mp.name; $Index++}#else {write-host " Found:"$MP.name} } if ($Index -eq 0) {Return $null}
To use the script,
.\enum-dbtoMP.ps1 -servername "DAG1S1"or
Get-MailboxServer | %{write-host $_.name;.\enum-dbtoMP.ps1 -servername $_.name}
This returns something like:
Mount points that don't have matching DBs !Found: D:\$RECYCLE.BIN\S-1-5-21-2159599067-3077033605-2888957035-43652\$REECZVX
Oh, My! I deleted the mount point, but now it's sitting in the recycle bin. As I skim down the report, I find a number of former database location that the mount point is no longer needed. Typically I go into the HP Array config GUI and simply delete these mount points for later use.
No comments:
Post a Comment