Get SharePoint 2013 Server Disk Space using PowerShell

Get Server Disk Space using powershell
InfoPath alternatives for form designing SharePoint

Scenario / Issue:
It is always a challenging task to validate the disk space on server using RDP (Remote Desktop Protocol) when you have a larger FARM or Network configured in your organization. Through you are ready to do RDP on all the servers it will be really hectic to sum-up all the used space and free space on every drive.

In this article I would like to introduce a quick want to avoid this legacy and manual way of validating disk space on servers. PowerShell has an extremely powerful objects / methods and techniques to break this hard edge.

Solution:
I have created a PowerShell script which will be really handy to administrators to validate the disk space on every server from his/her local machine. You can run Visual Studio Code to write, run , debug and test PowerShell script.



function Get-RemoteComputerDisk ($RemoteCompterName) {
Begin {
$output = “Dive `t UsedSpace (in GB) `t freeSpace (in GB) `t totalSpace (in GB) `n”
}
Process {
$drivers = Get-WmiObject Win32_LogicalDisk -ComputerName $RemoteCompterName
Write-Host “Server Name=” $RemoteCompterName
$totalDiskSpace = 0
foreach ($drive in $drivers) {
$driverName = $drive.DeviceID
$freespace = [int] ($drive.freeSpace / 1GB)
$totalspace = [int] ($drive.Size / 1GB)
$usedspace = $totalspace – $freespace
$output = $output + $driverName + “`t`t” + $usedspace + “`t`t`t” + $freespace + “`t`t`t” + $totalspace + “`n”
$totalDiskSpace = $totalDiskSpace + $totalspace
}
Write-Host “Total Disk Space= “$totalDiskSpace
}
End {
return $output
}
}
$srvName = Read-Host “Please enter the Server Name”
Get-RemoteComputerDisk -RemoteCompterName $srvName

This will provide the below output:

Get Server Disk Space using powershell
Get Server Disk Space using powershell

Hope this helps !!!!

Similar SharePoint 2013 Tutorials

About Krishna Vandanapu

I am Krishna.Vandanapu a SharePoint architect working in IT from last 12 years, I worked in SharePoint 2007, 2010, 2013, 2016 and Office 365. I have extensive hands on experience in customizing SharePoint sites from end to end. Expertise in SharePoint migration tools like Sharegate, Doc Ave and Metalogix. Migrated SharePoint sites from SharePoint 2007 to 2010 and 2010 to 2013 several times seamlessly. Implementing CSOM with Microsoft best practices. Spent quality time in configuring SharePoint application services like User Profile, Search, Managed Meta data services etc. Now exploring SharePoint Framework and SharePoint 2019

View all posts by Krishna Vandanapu →

Leave a Reply