Najtsob
Enthusiast
Enthusiast

Two questions about Set-HardDisk cmdlet

First:
When I executes cmdlet "Set-HardDisk" I get the following error:

Set-HardDisk        While performing operation 'Connect to host service 'https://test.demo.local/sdk' at port 902' the following error occured: 'Insufficient permissions in host

operating system'   

At line:1 char:21

+ $disk | Set-HardDisk <<<<  -CapacityKB 716800 -HostCredential $VsphereCred -GuestCredential $GuestVM

    + CategoryInfo          : OperationStopped: (:) [Set-HardDisk], VimException

    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_VixWaitForJob_VixError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.SetHardDisk


What priviliges do I need to execute this cmdlet ?
If I log into Vsphere with the same username and password that I used for -HostCredential, then I can edit disk size through Vsphere.

Second:
Is there another cmdlet like "Set-HardDisk" which would just expand virtual disk without expanding guest OS disk/partition.

Best regards, Primoz

0 Kudos
13 Replies
LucD
Leadership
Leadership

From the error message it looks as if the VIX connection to your guest failed.

Are the guest credentials correct ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
admin
Immortal
Immortal

Hi Najtsob,

Set-HardDisk can expand just the virtual disk - just don't specify host and guest credentials. If you do specify them, then the cmdlet will also extend the guest OS disk.

Regards,

Dimitar

Najtsob
Enthusiast
Enthusiast

From the error message it looks as if the VIX connection to your guest failed.

Are the guest credentials correct ?

Yes they are correct. I use the same variable which holds this credentials as parameter for other cmdlets (Get-WmiObject,...) and thy all works.

0 Kudos
Najtsob
Enthusiast
Enthusiast

Thank you. This answers my second question.

0 Kudos
Najtsob
Enthusiast
Enthusiast

Now I have the third question :smileyblush:

How can I know which disk in Guest Os corespond to which disk that I get with comand $myVM.HardDisks ?

0 Kudos
admin
Immortal
Immortal

I'm afraid that's not a trivial task. We use the BusNumber of the scsi controller that the virtual hdd is attached to in combination with the UnitNumber of the disk. Take a look at the "GuestDiskExpansion_winXPProGuest.bat" to see how these are used to determine the guest OS disk (the script is located in <PowerCLI_install_dir>\Scripts). However it's not aways possible to determine the guest disk (e.g. OS limitation) so we may require the user to explicitly specify the partition he wants to resize.

0 Kudos
Najtsob
Enthusiast
Enthusiast

Let's say I want to exted disk 😧

Is it posible to reliably determ which VM disk I need to resize ?


$myVM.Guest.Disks returns list of disks that are avaliable in Guest OS

0 Kudos
avlieshout
VMware Employee
VMware Employee

Have a look at my blog post :

http://www.van-lieshout.com/2010/02/powercli-match-vm-and-windows-harddisks-part-2/

The script will do the job you're looking for. Note however that the script will work with only the LSI logic controller.

If you're using a different controller, output might not be correct and you cannot use different type of controllers in your VM.

In our upcoming PowerCLI book (www.powerclibook.com) will be an updated version of this script that works with all controller types.

Arnim

Arnim van Lieshout Blogging: http://www.van-lieshout.com Twitter: http://www.twitter.com/avlieshout If you find this information useful, please award points for "correct" or "helpful".
Najtsob
Enthusiast
Enthusiast

Can you please post this updated script here ?

Many thanks.

0 Kudos
avlieshout
VMware Employee
VMware Employee

Sorry, not allowed to. You have to do it with the old version for now.

Just give that a try.

Arnim

Arnim van Lieshout Blogging: http://www.van-lieshout.com Twitter: http://www.twitter.com/avlieshout If you find this information useful, please award points for "correct" or "helpful".
0 Kudos
Najtsob
Enthusiast
Enthusiast

Does your script work if controller is "LSI Logic Parallel" ?

I'm asking because I'm getting wrong results Smiley Sad

EDIT:

It seems to work if subtract two insted of one.


$DiskMatch = $WinDisks | ?{($_.SCSIPort – 2) -eq $VirtualSCSIController.BusNumber -and $_.SCSITargetID -eq $VirtualDiskDevice.UnitNumber}

0 Kudos
Najtsob
Enthusiast
Enthusiast

Why I can't reward any points for correct and helpful answer ? When I click one of those buttons nothing happens.

0 Kudos
DSTAVERT
Immortal
Immortal

There is an issue with that on the forums for now. Just make sure you mark the questions as answered.

-- David -- VMware Communities Moderator
0 Kudos