-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGet-DiskDriveSpace.ps1
More file actions
32 lines (27 loc) · 1.22 KB
/
Copy pathGet-DiskDriveSpace.ps1
File metadata and controls
32 lines (27 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ValidationTags#Messaging,FlowControl,Pipeline,CodeStyle#
function Get-DiskDriveSpace {
<#
.SYNOPSIS
Pulls back Drive space info against a server.
.DESCRIPTION
This script is part of the ITAM process and is called by the Start-ServerAssetScan.ps1 script
.PARAMETER WhatIf
Shows what would happen if the command were to run. No actions are actually performed.
.EXAMPLE
PS C:\> Get-DiskDriveSpace -AssetID 1000 -AssetName LocalHost -AssetType 1
Runs a disk space check against the local system, with a type of SQL server
#>
[CmdletBinding()]
param (
[object[]]$AssetID,
[object[]]$AssetName,
[object[]]$AssetType
)
process {
$MyResults = Get-WmiObject -ComputerName $AssetName -Class Win32_logicaldisk -Filter "DriveType = '3'" |
Select-Object -Property @{N='Asset_ID';E={$AssetID}}, DeviceID, DriveType, VolumeName,
@{L="Capacity";E={"{0:N2}" -f ($_.Size/1GB)}},
@{L='FreeSpaceGB';E={"{0:N2}" -f ($_.FreeSpace /1GB)}} | ConvertTo-DbaDataTable
Write-DbaDataTable -InputObject $MyResults -SqlInstance Localhost -Database ITAM -Table stage.Server_Drive_Space -AutoCreateTable -Verbose
}
}