Expand VHD window 2003 is no longer moving into the new space


i using powershell script expand vhds. @ 1 time able expand drives , windows 2003 move newly added space. no longer working new space seen unpartitioned space. know there several work around fix issue can tell me why funtionality changed.

here script have been using

 

thanks in advance

sc

# expand vhd

param(

[string]$vhdpath = $(throw "must specify full path vhd"),

[string]$vhdsize = $(throw "must specify expansion add vhd (in mb)"))

 

 

# size in bytes

$mb = [system.uint64] $vhdsize*1024*1024

#obtain msvm_imagemanagementservice class

$imagemgtservice = get-wmiobject -class "msvm_imagemanagementservice" -namespace "root\virtualization"

# create dynamic vhd

$result = $imagemgtservice.expandvirtualharddisk($vhdpath,$mb)

#return success if return value "0"

if ($result.returnvalue -eq 0)

{write-host "operation completed sucessfully"}

#if return value not "0" or "4096" operation failed

elseif ($result.returnvalue -ne 4096)

{write-host "operation failed"}

else {#get job object

$job=[wmi]$result.job

#provide updates if jobstate "3" (starting) or "4" (running)

while ($job.jobstate -eq 3 -or $job.jobstate -eq 4)

{write-host $job.percentcomplete

start-sleep 1

 

#refresh job object

$job=[wmi]$result.job}

#a jobstate of "7" means success

if ($job.jobstate -eq 7)

{write-host "operation completed sucessfully"}

else

{write-host "operation failed"

write-host "errorcode:" $job.errorcode

write-host "errordescription" $job.errordescription}

}

hi,

 

if extend vhd file through script or gui such hyper-v manager, symptom encountered expected behavior.

 

for example, original vhd 30gb, extend 50gb, after extend, able find 20gb’s unallocated disk space @ end of disk.

 

by way, system behavior, need extend yourself, or can create new partition/volume.

 

in addition, if have 1 partition(c: drive) within windows server 2003 vm, not able extend system partition directly, because don’t support extend system partition in windows server 2003. more information, can refer following post.

 

extending boot partition hyper-v vm disk

http://social.technet.microsoft.com/forums/en/winserverhyperv/thread/d0912ef9-be5b-44c0-962e-1740190f0376

 

 

best regards,

vincent hu

 



Windows Server  >  Hyper-V



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL