PowerShell for Windows Admins

Jul 7 2011   2:23PM GMT

Next partition



Posted by: Richard Siddaway
Disks

I also need to generate a partition number for Mount-VHD

Similar idea but use the Win32_DiskPartition class

function get-nextpartition {            
            
$disk = Get-WmiObject -Class Win32_DiskPartition |            
sort Index -Descending |            
select -First 1 -Property Index            
            
$nextindex = ($disk.Index) + 1            
$nextindex            
            
}

The Index is an integer so we only need to add 1

Comment on this Post

Leave a comment: