Drive Space Information
One of the scripts which I need to use on a daily basis. This is a basic function of the script to get information on drive space. We can take the result and get a report emailed as a table put into a web page, or simply export it as a CSV file and manipulate as per your need. Usually, I export it as CSV and do some manual manipulation to filter the data which I require. Planning to do some automation on it. I will update the post as I do it... Enjoy!!!
<#.SYNOPSISPowerShell script to report on drive space available on remote windows systems..DESCRIPTIONGet the Availbale Max, availabe drive space information remotely and report it to admins..PARAMETER ComputerNameAccepts a list of computer names or IP addresses.EXAMPLEGet-DriveSpace -ComputerName Server1,server2.LINKhttps://posh-scripting.blogspot.in/2017/01/drive-space-information.html#>function Get-DriveSpace{[CmdletBinding()]Param(# A computer name or list of computer names[Parameter(Mandatory=$False,ValueFromPipelineByPropertyName=$true,Position=0)][string[]]$ComputerName = 'localhost')$outObject = @()foreach ($computer in $ComputerName){$tempObject = Get-WmiObject -Class win32_logicaldisk -ComputerName $computer -Filter "DriveType = 3" | `Select-Object `@{n='ComputerName';e={$_.PSComputerName}},`DeviceID,`FileSystem,`@{n='Size GB';e={"{0:N2}" -f ([math]::Round($_.Size/1GB))}},`@{n='FreeSpace';e={"{0:N2}" -f ($_.FreeSpace /1GB)}},`@{n='% Free Space';e={"{0:N2}" -f ($_.FreeSpace / $_.Size * 100)}}$outObject += $tempObject}return $outObject}
Comments
Post a Comment