VMware Cloud Community
COS
Expert
Expert

Grow a VMs disk via PowerCLI - Getting error 'The system cannot find the drive specified.'

I am trying to increase the C: drive of a VM with the below command....

Get-HardDisk -vm "test-diskbump" | where {$_.Name -eq "Hard Disk 1"} | Set-HardDisk -CapacityGB 155 -ResizeGuestPartition -Confirm:$false

It actually increased the VMdk but when it tries to adjust the partition, I get the below Error....

"Execution of the  script in guest OS on VM 'test-diskbump' failed: 'The system cannot find the drive specified."

So I tested segments of the script.

The below returns correct data with no error...

Get-HardDisk -vm "ps-laoyang" | where {$_.Name -eq "Hard Disk 1"}

CapacityGB      Persistence                                                    Filename

----------      -----------                                                    --------

155.000         Persistent              [vmware-nfstest] test-diskbump/test-diskbump.vmdk

Looks good so far.

But when I add the "-ResizeGuestPartition -Confirm:$false" I get the error below...

"Execution of the  script in guest OS on VM 'test-diskbump' failed: 'The system cannot find the drive specified."

any ideas?

Reply
0 Kudos
5 Replies
Zsoldier
Expert
Expert

  1. The "ResizeGuestPartition" is a deprecated switch and only works on XP SP3 and RHEL 5.

You have to do:

$GuestCredentials = Get-Credential

Get-HardDisk -vm "test-diskbump" | where {$_.Name -eq "Hard Disk 1"} | Set-HardDisk -CapacityGB 155 -GuestCredential $GuestCreds -Confirm:$false

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
Reply
0 Kudos
a_p_
Leadership
Leadership

Which PowerCLI version, and which guest OS do you use?

How does the current partition layout on the virtual disk that you want to expand look like?

André

Reply
0 Kudos
Zsoldier
Expert
Expert

My current versions:

Powershell Core 6.1.2

PowerCLI Core: 11.4.0.14413515

Unsure what the current partition layout would look like.  I'm guessing it just assumes a single partition and will expand that in the guest OS.

The example provided is pretty vague too:

    -------------------------- Example 2 --------------------------

   

    Set-HardDisk -HardDisk $harddisk -CapacityGB $extendedCapacity -GuestCredential $guestCred

   

    Extends a hard disk with the specified capacity. The command also extends the disk on the guest OS.

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
Reply
0 Kudos
COS
Expert
Expert

get-powercliversion

WARNING: The cmdlet "Get-PowerCLIVersion" is deprecated. Please use the 'Get-Module' cmdlet instead.

PowerCLI Version

----------------

   VMware PowerCLI 11.0.0 build 10380590

---------------

Component Versions

---------------

   VMware Cis Core PowerCLI Component PowerCLI Component 11.0 build 10335701

   VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 11.0 build 10336080

The guest is Windows 10 Pro BIOS version.

The drive has the first partition as "System Reserved" and the OS partition is the second partition.

Reply
0 Kudos
COS
Expert
Expert

You can't use passthrough authentication?

It prompts for credentials and we use PAM (Personal accounts management) where we don't know the password of our elevated accounts.

I tried: Get-HardDisk -vm "test-diskbump" | where {$_.Name -eq "Hard Disk 1"} | Set-HardDisk -CapacityGB 155

It added the space but did not adjust the partition.

Reply
0 Kudos