Skip to content

Instantly share code, notes, and snippets.

@brettmillerb
Created November 12, 2018 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettmillerb/aadc7c549a73fceb212aa01845c7a230 to your computer and use it in GitHub Desktop.
Save brettmillerb/aadc7c549a73fceb212aa01845c7a230 to your computer and use it in GitHub Desktop.
function Get-ShadowStorageSpace {
[CmdletBinding()]
param (
[Parameter(Mandatory,
Position = 0,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[string[]]
$ComputerName
)
process {
foreach ($computer in $ComputerName) {
$ShadowStorage = Get-CimInstance -ClassName Win32_ShadowStorage -ComputerName $computer
foreach ($disk in $ShadowStorage) {
$volObj = Get-CimInstance -ClassName win32_volume -ComputerName $computer | ? deviceid -eq $disk.volume.deviceid
[pscustomobject]@{
AllocatedSpace = "{0:N2} Gb ({1:N1}%)" -f ($disk.allocatedspace / 1GB), ($disk.UsedSpace / $volObj.Capacity * 100)
UsedSpace = "{0:N2} Gb" -f ($disk.usedspace / 1GB)
MaxSpace = "{0:N2} Gb" -f ($disk.maxspace / 1GB)
DriveLetter = $volObj.Name
ComputerName = $disk.pscomputername
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment