Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

get free space on mount points

$
0
0

Hi there

I have this idea of creating a script that will give me a quick glimps of free space on specific mount points for exchange database.

the big idea is since I have a lot I don't want to see it all so ill be prompt for specific one im interested in and will query exchange for the location of db/logs(its on same mount point location) and it will get me all copies(on multiple servers) and their free space.

anyway that's the big plan:)

all my mount points are in same folder  (M:\mp\db1...db100) so it should make it easier

just not sure on best way to grab those volumes and from there get the free space(since they are mount points)

this is rough start

# Load psssnapin
if (! (Get-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:SilentlyContinue) )
{
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:Stop
}
# Get Volume
Function Get-Volume ([string]$Path, [string]$Server) {
 Do
 {
  $parent = $Path -Replace "[^\\]*$"
  $Volume = Get-WmiObject -Class Win32_Volume -ComputerName $Server -Filter ("Name = '" + $parent.Replace("\","\\") + "'")
  $Path = $parent -Replace ".$"
  
 } While ($Volume -eq $null)
 return $Volume
}
# Get Transaction LOGs volume information (both Logical Drive and Mount Point): Name, Capacity, Free Space
    $databasename = get-mailboxdatabase $database
    $databasecopies = Get-MailboxDatabaseCopyStatus $databasename.name
    $servers = $databasecopies |select mailboxserver
    $dbFilePath = "$($databasename.EdbFilePath)\"
$database = Read-Host 'What is your database name'
$Data = @()
# Getting free space of each server mount point
foreach ($server in $servers)
{
$DbVolume = Get-Volume -Path $dbFilePath -ServerName $Server
}
$Data | ConvertTo-CSV | Out-File C:\Data.csv

I noticed atleast my first problem is that im not getting the server names

[PS] C:\Windows\system32>$servers |FL


MailboxServer : EX1

MailboxServer : EX2

MailboxServer : EX3

MailboxServer : EX4

not sure how to handle that and strip it so I'm left with server names so I can pipe it to foreach

 

any help would be welcome


Viewing all articles
Browse latest Browse all 6937

Trending Articles