VMware Cloud Community
b_johnston
Contributor
Contributor

SCSI ID change error after upgrading PowerCLI to 6.5

This worked in PowerCLI 5.5 but fails in PowerCLI 6.5.  How can I change the SCSI ID of a harddisk in 6.5?  I get this error:

Exception setting "device": "Cannot convert the "VMware.Vim.VirtualDisk" value of type "VMware.Vim.VirtualDisk" to type "VMware.Vim.VirtualDevice"."

At line:1 char:1

+ $spec.deviceChange[0].device = $disktochange.ExtensionData

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException

    + FullyQualifiedErrorId : ExceptionWhenSetting

This code Works fine before upgrading to PowerCLI 6.5:

                   $thisvm = Get-VM $vmname

                    $disktochange = Get-HardDisk -VM $thisvm -Name 'Hard disk 3'           

                    #change disk 3 to SCSI ID 1:0 since it defaults to 1:2

                    ## create a new VirtualMachineConfigSpec, with which to make the change to the VM's disk

                    $spec = New-Object VMware.Vim.VirtualMachineConfigSpec

                    ## create a new VirtualDeviceConfigSpec

                    $spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec

                    $spec.deviceChange[0].operation = 'edit'

                    ## populate the 'device' property with the existing info from the hard disk to change

                    $spec.deviceChange[0].device = $disktochange.ExtensionData

                    ## then, change the second part of the SCSI ID (the UnitNumber)

                    $spec.deviceChange[0].device.unitNumber = 0

                    ## reconfig the VM with the updated ConfigSpec (VM must be powered off)

                    $thisvm.ExtensionData.ReconfigVM_Task($spec)

Reply
0 Kudos
9 Replies
LucD
Leadership
Leadership

I can't seem to replicate that error you are seeing.

Works fine in PowerCLI 10.2.0.

Is there a specific reason you want to use the older PowerCLI 6.5?


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

Reply
0 Kudos
b_johnston
Contributor
Contributor

Thanks.  I did not realize that it went form 6.5 to 10.  Working on installing 10.2 now.

Reply
0 Kudos
b_johnston
Contributor
Contributor

Ok after dumping PowerCLI 6.5 and installing PowerCLI 10.2 using  Install-Module -Name VMware.PowerCLI -Scope AllUsers -Force -AllowClobber .

I keep getting a could not load file or assembly error.  I've searched all over for a solution but something is broken.  I guess the install-module feature that VMware changed to as opposed to just giving us an executable is broken.  Seems that tons of other users are having the same issue.

owercli Core Snapin already loaded.


connect-viserver : Could not load file or assembly 'VMware.Vim, Version=6.7.0.1174, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

At C:\scripts\vmware\VMWare_Connect-VIServer_Test.ps1:49 char:1

+ connect-viserver $vcenter -User $user -Password $pwd -WarningAction S ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Connect-VIServer], FileNotFoundException

    + FullyQualifiedErrorId : System.IO.FileNotFoundException,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

 

Reply
0 Kudos
LucD
Leadership
Leadership

That's most probably the log4net.dll issue you are hitting.

Not a real fix, more of a bypass, is the following procedure:

  • Create folder C:\Windows\assembly\GAC_64\log4net\1.2.10.0__692fbea5521e1304
  • Copy log4net.dll from C:\Program Files\WindowsPowerShell\Modules\VMware.VimAutomation.Sdk\11.0.0.10334495\net45\log4net.dll to this folder
  • restart PowerShell


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

Reply
0 Kudos
b_johnston
Contributor
Contributor

I can't create a folder in C:\Windows\assembly\.  I did try powercli11.0 on a new server and it works fine now.  The only problem is my move-vm command is now broken.  This user was able to move vms before and now it's broken.  Not that big of a deal though since we are dealing with different versions of PowerCLI and VSphere.  Thanks for the help!

PS> move-vm -destination $vFolder -VM $buildvm -WarningAction SilentlyContinue


move-vm : 10/11/2018 10:59:13 PM Move-VM Permission to perform this operation was denied. Required privilege 'Resource.ColdMigrate' on managed object with id 'VirtualMachine-vm-833352'.

At line:1 char:1

+ move-vm -destination $vFolder -VM $buildvm -WarningAction SilentlyCon ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Move-VM], NoPermission

    + FullyQualifiedErrorId : Client20_VMServiceImpl_RelocateVM_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

Reply
0 Kudos
LucD
Leadership
Leadership

You need to be a local administrator to create that folder.

The Move-VM issue seems to be more of permission problem.

What role does that user have on the source and destination locations?


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

Reply
0 Kudos
b_johnston
Contributor
Contributor

It's the same user that was able to create and move VMs before upgrading.

Reply
0 Kudos
LucD
Leadership
Leadership

It might be that the new vSphere version is missing some permissions, or requires different permissions.

You could check the vpxd log to see which permission exactly is missing.


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

Reply
0 Kudos
b_johnston
Contributor
Contributor

That sounds about right.  I'll check with our VM admins to see what may be missing since the upgrade.  I really appreciate the rapid response and assistance!

Reply
0 Kudos