Skip to content

Instantly share code, notes, and snippets.

@gravejester
Created May 10, 2015 13:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gravejester/3a42464740a1d2a56c4a to your computer and use it in GitHub Desktop.
Save gravejester/3a42464740a1d2a56c4a to your computer and use it in GitHub Desktop.
function Update-PSDriveInfoType {
<#
Update PSDriveInfo type to include BlockSize
Author: Øyvind Kallstad
#>
$typeData = Get-TypeData System.Management.Automation.PSDriveInfo
$scriptBlock = {
if ($this.Provider.ImplementingType -eq [Microsoft.PowerShell.Commands.FileSystemProvider]) {
$driveRoot = ([System.IO.DirectoryInfo] $this.Root).Name.Replace('\','\\')
(Get-WmiObject -Query "SELECT BlockSize FROM Win32_Volume WHERE Name='$driveRoot'").BlockSize
}
}
$scriptProperty = New-Object System.Management.Automation.Runspaces.ScriptPropertyData 'BlockSize', $scriptBlock
if (-not($typeData.Members['BlockSize'])) {
$typeData.Members.Add('BlockSize', $scriptProperty)
}
Update-TypeData $typeData -Force
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment