PoshCode Archive  Artifact Content

Artifact 2514f231b1e446caaefc48e076a49b89e2f54b164d5c41fa70e5289c9add8bee:

  • File Show-Drive-Sizes.ps1 — part of check-in [fa61b81298] at 2018-06-10 13:41:00 on branch trunk — ############################################################################################# (user: Rob Sewell size: 2000)

# encoding: utf-8
# api: powershell
# title: Show Drive Sizes
# description: #############################################################################################
# version: 0.1
# type: function
# author: Rob Sewell
# license: CC0
# function: Show-DriveSizes
# x-poshcode-id: 4434
# x-archived: 2015-07-09T03:24:31
# x-published: 2015-09-01T11:00:00
#
# #
# NAME: Show-DriveSizes.ps1
# AUTHOR: Rob Sewell http://sqldbawiththebeard.com
# DATE:22/07/2013
# #
# COMMENTS: Load function for displaying drivesizes
# USAGE: Show-DriveSizes server1
# 覧覧覧覧覧覧覧覧覧覧覧覧
#

 #############################################################################################
#
# NAME: Show-DriveSizes.ps1
# AUTHOR: Rob Sewell http://sqldbawiththebeard.com
# DATE:22/07/2013
#
# COMMENTS: Load function for displaying drivesizes
# USAGE: Show-DriveSizes server1
# 覧覧覧覧覧覧覧覧覧覧覧覧


Function Show-DriveSizes ([string]$Server)
{
                            $Date = Get-Date
                            Write-Host -foregroundcolor DarkBlue -backgroundcolor yellow "$Server - - $Date"
    #interogate wmi service and return disk information
                            $disks=Get-WmiObject -Class Win32_logicaldisk -Filter "Drivetype=3" -ComputerName $Server
                            $diskData=$disks | Select DeviceID, VolumeName , 
    # select size in Gbs as int and label it SizeGb
                            @{Name="SizeGB";Expression={$_.size/1GB -as [int]}},
    # select freespace in Gbs  and label it FreeGb and two deciaml places
                            @{Name="FreeGB";Expression={"{0:N2}" -f ($_.Freespace/1GB)}},
    # select freespace as percentage two deciaml places  and label it PercentFree 
                            @{Name="PercentFree";Expression={"{0:P2}"  -f ($_.Freespace/$_.Size)}}
                            $diskdata | Format-table -AutoSize | Out-Host
                                                  
}