Created
May 10, 2015 13:49
-
-
Save gravejester/3a42464740a1d2a56c4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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