PowerShell Command
Get-wmiobject -computername $ServerName win32_logicaldisk -filter "drivetype='3'" | select @{Name="Computer Name";expression={$_.SystemName}},@{Name="Drive";expression={$_.deviceID}},@{Name="Volume Name";expression={$_.VolumeName}} ,@{Name="Free(GB)";expression={[math]::truncate($_.freespace/1.0GB)}},@{Name="% Free";Expression={[math]::truncate(($_.FreeSpace/$_.Size)*100)}}, @{Name="Total(GB)";expression={[math]::truncate($_.Size/1.0GB)}} | format-table -autosize
Note: Substitute 'localhost' with a remote system you want drive information for.
I have actually added the command line as a function into a .psm1 module file on our management server and then published the Powershell console through RDS so others can benefit from this tool among others I have created. I would highly recommend others consider adding any Powershell 'tools' they create into a module on a terminal server and then publish the shell for others to use. I have found this to be a particularly useful approach in a large organisation.
File Path:
C:\Windows\System32\WindowsPowerShell\v1.0\Modules\SCCM\SCCM.psm1
function Get-SCCMDriveSpace {
[CmdletBinding()]
PARAM
(
[Parameter(Mandatory=$true, HelpMessage="SCCM Site Server",ValueFromPipeline=$true)] $ServerName
)
Get-wmiobject -computername $ServerName win32_logicaldisk -filter "drivetype='3'" | select @{Name="Computer Name";expression={$_.SystemName}},@{Name="Drive";expression={$_.deviceID}},@{Name="Volume Name";expression={$_.VolumeName}} ,@{Name="Free(GB)";expression={[math]::truncate($_.freespace/1.0GB)}},@{Name="% Free";Expression={[math]::truncate(($_.FreeSpace/$_.Size)*100)}}, @{Name="Total(GB)";expression={[math]::truncate($_.Size/1.0GB)}} | format-table -autosize
}
Note: I have named this function SCCM so as to group it in Powershell help results with other SCCM Powershell tools that have been created for the support teams.
No comments:
Post a comment