Exchange Server Share

… Information sharing on Exchange Server …

Exchange Powershell Tip #05

leave a comment »

Exchange Powershell Tip #05

How much disk space I have on my Exchange 2010 or 2013 servers?

You can run below one liner that will get the list of all Exchange servers from your environment and gather Disk information through WMI for all of them. This includes disks with mount point folder path too if you have it configured instead of Drive Letter.

Get-ExchangeServer | Sort Name | ForEach{Get-WmiObject -query “Select * from Win32_Volume” -ComputerName $_ | Where{($_.Name -NotLike “\\?*”)} | Format-Table SystemName, Name, @{Name=”Total Size (GB)”;expression={[math]::Round($_.Capacity/1073741824,2)}}, @{Name=”Free Space (GB)”;expression={[math]::Round($_.FreeSpace/1073741824,2)}},@{Name=”Free(%)”;expression={([math]::Round($_.FreeSpace/$_.Capacity *100,2))}}}

Here is the sample output from my Exchange 2013 lab.

ExShellTip5-Space

You can use filter against Get-ExchangeServer to get this only for certain servers. For example, if I want disk space info for server names starting with EX2013* then you can use this…

Get-ExchangeServer EX2013* | Sort Name | ForEach{Get-WmiObject -query “Select * from Win32_Volume” -ComputerName $_ | Where{($_.Name -NotLike “\\?*”)} | Format-Table SystemName, Name, @{Name=”Total Size (GB)”;expression={[math]::Round($_.Capacity/1073741824,2)}}, @{Name=”Free Space (GB)”;expression={[math]::Round($_.FreeSpace/1073741824,2)}},@{Name=”Free(%)”;expression={([math]::Round($_.FreeSpace/$_.Capacity *100,2))}}}

If it is not an Exchange server, no worries, you can pass the server name(s) in front of cmdlet like this…

@(“ServerName1″,”ServerName2”) | ForEach{Get-WmiObject -query “Select * from Win32_Volume” -ComputerName $_ | Where{($_.Name -NotLike “\\?*”)} | Format-Table SystemName, Name, @{Name=”Total Size (GB)”;expression={[math]::Round($_.Capacity/1073741824,2)}}, @{Name=”Free Space (GB)”;expression={[math]::Round($_.FreeSpace/1073741824,2)}},@{Name=”Free(%)”;expression={([math]::Round($_.FreeSpace/$_.Capacity *100,2))}}}

Or get the server names from a file which has one server name in each line, like this…

Get-Content C:\Temp\Servers.txt | ForEach{Get-WmiObject -query “Select * from Win32_Volume” -ComputerName $_ | Where{($_.Name -NotLike “\\?*”)} | Format-Table SystemName, Name, @{Name=”Total Size (GB)”;expression={[math]::Round($_.Capacity/1073741824,2)}}, @{Name=”Free Space (GB)”;expression={[math]::Round($_.FreeSpace/1073741824,2)}},@{Name=”Free(%)”;expression={([math]::Round($_.FreeSpace/$_.Capacity *100,2))}}}

However if you have hundreds of servers in your environment and you want to export the result into CSV, use this…

Get-ExchangeServer | Sort Name | ForEach{Get-WmiObject -query “Select * from Win32_Volume” -ComputerName $_ | Where{($_.Name -NotLike “\\?*”)} | Select SystemName, Name, @{Name=”Total Size (GB)”;expression={[math]::Round($_.Capacity/1073741824,2)}}, @{Name=”Free Space (GB)”;expression={[math]::Round($_.FreeSpace/1073741824,2)}},@{Name=”Free(%)”;expression={([math]::Round($_.FreeSpace/$_.Capacity *100,2))}}} | Export-CSV C:\Femp\DiskSpaceInfo.csv

==> Get All Exchange Powershell Tips from the Archive Here<==

Written by Amit Tank

May 26, 2016 at 5:00 pm

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: