VMware Cloud Community
AntoP
Contributor
Contributor
Jump to solution

Adding 2 SCSI controllers and multiple shared disks to 2 servers - powercli - error: Exception calling "ReconfigVM" with "1" argument(s): "Invalid configuration for device '0'."

Hi there,

I'm trying to build script to automate the creating of some clusters (Ora RAC). I can build the VMs and add 2 controllers to each node but it fails to add any of the required disks. I've enclosed the creation of each "pair of disks" in its own function but I'm getting the error below, I believe the error refers to one of the parameters used for the first disk is not built correctly but after 2 days looking and having tried more traditional approaches, I fail to see what disk parameters is causing the error, any help is very much appreciated. Here is the code and the error:

Code:

function createocr01 {

Function New-SCSICtrl {

Param (

[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]

$vm

)

Process {

$global:VMSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

$VMSpec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[](2)

$VMSpec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec

$VMSpec.deviceChange[0].operation = "add"

$VMSpec.deviceChange[0].device = New-Object VMware.Vim.ParaVirtualSCSIController

$Busnumber = ($vm.ExtensionData.Config.Hardware.device | Where { $_.gettype().Name -eq "ParaVirtualSCSIController" } | Select -ExpandProperty busnumber | Sort-Object -Descending | Select -First 1) +1

$VMspec.deviceChange[0].device.busnumber = $Busnumber

$VMspec.deviceChange[0].device.deviceInfo = New-Object VMware.Vim.Description

$VMspec.deviceChange[0].device.deviceInfo.summary = ''

$VMspec.deviceChange[0].device.deviceInfo.label = 'New SCSI controller'

$VMspec.deviceChange[0].device.sharedBus = 'Physical'

$VMspec.deviceChange[0].device.key = -1

$VMSpec.deviceChange[1] = New-Object VMware.Vim.VirtualDeviceConfigSpec

$VMSpec.deviceChange[1].operation = "add"

$VMSpec.deviceChange[1].device = New-Object VMware.Vim.ParaVirtualSCSIController

$Busnumber = ($vm.ExtensionData.Config.Hardware.device | Where { $_.gettype().Name -eq "ParaVirtualSCSIController" } | Select -ExpandProperty busnumber | Sort-Object -Descending | Select -First 1) +1

$VMspec.deviceChange[1].device.busnumber = $Busnumber

$VMspec.deviceChange[1].device.deviceInfo = New-Object VMware.Vim.Description

$VMspec.deviceChange[1].device.deviceInfo.summary = ''

$VMspec.deviceChange[1].device.deviceInfo.label = 'New SCSI controller'

$VMspec.deviceChange[1].device.sharedBus = 'Physical'

$VMspec.deviceChange[1].device.key = -1

$vm.ExtensionData.ReconfigVM($VMSpec)     

}

}

Function add-dsk-node1 {

Param (

[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]

$vm

)

Process {

$DiskPathocr01 = "[datastore 1] QA-Shared/ProdOcr1.vmdk"

[int]$diskSizeGB = 10

[int]$diskControllerNumber = 1

[int]$diskUnitNumber = 0

$vmName = Get-VM $node1 | select Name

$node = Get-View -ViewType VirtualMachine -Property Name,Config.Hardware.Device -Filter @{"Name" = $vmName.Name}

[int64]$diskSizeInKB = (($diskSizeGB * 1024 * 1024 * 1024)/1KB)

$diskSizeInKB = [Math]::Round($diskSizeInKB,4,[MidPointRounding]::AwayFromZero)

$controller = Get-ScsiController -VM $vm | where{$_.ExtensionData.busNumber -eq $diskControllerNumber}

$diskControllerKey = $controller.ExtensionData.Key

# Create Config Spec to add new VMDK & Enable Multi-Writer Flag

$global:spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[](1)

$spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec

$spec.deviceChange[0].operation = "add"

$spec.DeviceChange[0].FileOperation = "create"

$spec.deviceChange[0].device = New-Object VMware.Vim.VirtualDisk

$spec.deviceChange[0].device.key = -1

$spec.deviceChange[0].device.ControllerKey = $diskControllerKey

$spec.deviceChange[0].device.CapacityInKB = $diskSizeInKB

$spec.DeviceChange[0].device.backing = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

$spec.DeviceChange[0].device.backing.fileName = $DiskPathocr01

$spec.DeviceChange[0].device.backing.diskMode = 'independent_persistent'

$spec.deviceChange[0].device.backing.thinProvisioned = $false

$spec.deviceChange[0].device.backing.split = $false

$spec.deviceChange[0].device.backing.writeThrough = $false

$spec.deviceChange[0].device.backing.eagerlyScrub = $true

$spec.extraConfig = New-Object VMware.Vim.OptionValue[](1)

$spec.extraConfig[0] = New-Object VMware.Vim.OptionValue

$spec.extraConfig[0].key = "scsi" + $diskControllerNumber + ":" + $diskUnitNumber + ".sharing"

$spec.extraConfig[0].value = "multi-writer"

$vm.ExtensionData.ReconfigVM($spec)

}

}

Function add-dsk-node2 {

Param (

[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]

$vm

)

Process {

$DiskPathocr01 = "[datastore1] QA-Shared/ProdOcr1.vmdk"

[int]$diskSizeGB = 10

[int]$diskControllerNumber = 1

[int]$diskUnitNumber = 0

$vmName = Get-VM $node2 | select Name

$node = Get-View -ViewType VirtualMachine -Property Name,Config.Hardware.Device -Filter @{"Name" = $vmName.Name}

[int64]$diskSizeInKB = (($diskSizeGB * 1024 * 1024 * 1024)/1KB)

[int64]$diskSizeInKB = [Math]::Round($diskSizeInKB,4,[MidPointRounding]::AwayFromZero)

$controller = Get-ScsiController -VM $vm | where{$_.ExtensionData.busNumber -eq $diskControllerNumber}

$diskControllerKey = $controller.ExtensionData.Key

# Create Config Spec to add new VMDK & Enable Multi-Writer Flag

$global:spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[](1)

$spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec

$spec.deviceChange[0].operation = "add"

$spec.deviceChange[0].device = New-Object VMware.Vim.VirtualDisk

$spec.deviceChange[0].device.key = -1

$spec.deviceChange[0].device.ControllerKey = $diskControllerKey

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

$spec.deviceChange[0].device.CapacityInKB = $diskSizeInKB

$spec.DeviceChange[0].device.backing = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

$spec.DeviceChange[0].device.backing.fileName = $DiskPathocr01

$spec.DeviceChange[0].device.backing.diskMode = 'independent_persistent'

$spec.DeviceChange[0].device.backing.eagerlyScrub = $True

$spec.extraConfig = New-Object VMware.Vim.OptionValue[](1)

$spec.extraConfig[0] = New-Object VMware.Vim.OptionValue

$spec.extraConfig[0].key = "scsi" + $diskControllerNumber + ":" + $diskUnitNumber + ".sharing"

$spec.extraConfig[0].value = "multi-writer"

$vm.ExtensionData.ReconfigVM($spec)

}

}

$node1 | New-SCSICtrl

$node2 | New-SCSICtrl

#Get-VM $node1, $node2 | Get-ScsiController

$node1 | add-dsk-node1

$node2 | add-dsk-node2

}

Error:

Exception calling "ReconfigVM" with "1" argument(s): "Invalid configuration for device '0'."

At C:\Users\d220322\Desktop\scripts\tokendb-deploy.ps1:252 char:4

+             $vm.ExtensionData.ReconfigVM($spec)

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

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

    + FullyQualifiedErrorId : VimException

Thanks in advanced!

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The attached version seems to work for me.

Note that the QA-Shared needs to exist on the datastore.


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

View solution in original post

8 Replies
LucD
Leadership
Leadership
Jump to solution

The attached version seems to work for me.

Note that the QA-Shared needs to exist on the datastore.


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

satheeshsatz
Enthusiast
Enthusiast
Jump to solution

Also please note that, we are suffering now as this way of provisioning storage wont support storage vmotion, so if the size is huge it is very tough to get migrated, incase of EOW on the storage controller.

As we are facing this issue now, though of putting it here.

Regards, Satheesh
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Not sure what you mean with that last remark?

Is the script I provided working?


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

Reply
0 Kudos
AntoP
Contributor
Contributor
Jump to solution

Hi,

Thanks for your help. That code wouldn't work for me, it only creates 1 controller.

I see you've added $ds, I thought it wouldn't be need it when specifying FileName. Thanks anyway, you put me in the correct path. Here is the code that worked for me. The only remaining item is 'multi-writer' the below code still doesn't set that advanced property

function createocr01 {

    Function New-SCSICtrl {

        Param (

            [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True)]

            $vm

        )

        Process {

            $global:VMSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

            $VMSpec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[](2)

            $VMSpec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec

            $VMSpec.deviceChange[0].operation = "add"

            $VMSpec.deviceChange[0].device = New-Object VMware.Vim.ParaVirtualSCSIController

            $VMspec.deviceChange[0].device.busnumber = 1

            $VMspec.deviceChange[0].device.deviceInfo = New-Object VMware.Vim.Description

            $VMspec.deviceChange[0].device.deviceInfo.summary = ''

            $VMspec.deviceChange[0].device.deviceInfo.label = 'New SCSI controller'

            $VMspec.deviceChange[0].device.sharedBus = 'Physical'

            $VMspec.deviceChange[0].device.key = -1

            $VMSpec.deviceChange[1] = New-Object VMware.Vim.VirtualDeviceConfigSpec

            $VMSpec.deviceChange[1].operation = "add"

            $VMSpec.deviceChange[1].device = New-Object VMware.Vim.ParaVirtualSCSIController

            $VMspec.deviceChange[1].device.busnumber = 2

            $VMspec.deviceChange[1].device.deviceInfo = New-Object VMware.Vim.Description

            $VMspec.deviceChange[1].device.deviceInfo.summary = ''

            $VMspec.deviceChange[1].device.deviceInfo.label = 'New SCSI controller'

            $VMspec.deviceChange[1].device.sharedBus = 'Physical'

            $VMspec.deviceChange[1].device.key = -2

            $vm.ExtensionData.ReconfigVM($VMSpec)    

        }

    }

    

    Function add-dsk-node1 {

        Param (

            [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True)]

            $vm

        )

        Process {

            $DiskPathocr01 = ""[datastore1] Shared/QAOcr1.vmdk""

            $storeocr01 = "datastore1"

            $ds = Get-Datastore -Name $storeocr01

            [int]$diskSizeGB = 10

            [int]$diskControllerNumber = 1

            [int]$diskUnitNumber = 0

            $vmName = Get-VM $node1 | select Name

            $node = Get-View -ViewType VirtualMachine -Property Name, Config.Hardware.Device -Filter @{"Name" = $vmName.Name}

            [int64]$diskSizeInKB = (($diskSizeGB * 1024 * 1024 * 1024) / 1KB)

            [int64]$diskSizeInKB = [Math]::Round($diskSizeInKB, 4, [MidPointRounding]::AwayFromZero)

            $controller = Get-ScsiController -VM $vm | where {$_.ExtensionData.busNumber -eq $diskControllerNumber}

            $diskControllerKey = $controller.ExtensionData.Key

            # Create Config Spec to add new VMDK & Enable Multi-Writer Flag

            $global:spec = New-Object VMware.Vim.VirtualMachineConfigSpec

            $spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[](1)

            $spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec

            $spec.deviceChange[0].operation = "add"

            $spec.DeviceChange[0].FileOperation = "create"

            $spec.deviceChange[0].device = New-Object VMware.Vim.VirtualDisk

            $spec.deviceChange[0].device.key = -1

            $spec.deviceChange[0].device.ControllerKey = $diskControllerKey

            $spec.deviceChange[0].device.CapacityInKB = $diskSizeInKB

            $spec.DeviceChange[0].Device.UnitNumber = $diskUnitNumber

            $spec.DeviceChange[0].device.backing = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

            $spec.DeviceChange[0].device.backing.Datastore = $ds.ExtensionData.MoRef

            $spec.DeviceChange[0].device.backing.fileName = $DiskPathocr01

            $spec.DeviceChange[0].device.backing.diskMode = 'independent_persistent'

            $spec.deviceChange[0].device.backing.thinProvisioned = $false

            $spec.deviceChange[0].device.backing.split = $false

            $spec.deviceChange[0].device.backing.writeThrough = $false

            $spec.deviceChange[0].device.backing.eagerlyScrub = $true

            $spec.extraConfig = New-Object VMware.Vim.OptionValue[](1)

            $spec.extraConfig[0] = New-Object VMware.Vim.OptionValue

            $spec.extraConfig[0].key = "scsi" + $diskControllerNumber + ":" + $diskUnitNumber + ".sharing"

            $spec.extraConfig[0].value = "multi-writer"

            $vm.ExtensionData.ReconfigVM($spec)

        }

    }

    

    Function add-dsk-node2 {

        Param (

            [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True)]

            $vm

        )

        Process {

            $DiskPathocr01 = "[datastore1] Shared/QAOcr1.vmdk"

            $storeocr01 = "datastore1"

            $ds = Get-Datastore -Name $storeocr01

            [int]$diskSizeGB = 10

            [int]$diskControllerNumber = 1

            [int]$diskUnitNumber = 0

            $vmName = Get-VM $node2 | select Name

            $node = Get-View -ViewType VirtualMachine -Property Name, Config.Hardware.Device -Filter @{"Name" = $vmName.Name}

            [int64]$diskSizeInKB = (($diskSizeGB * 1024 * 1024 * 1024) / 1KB)

            [int64]$diskSizeInKB = [Math]::Round($diskSizeInKB, 4, [MidPointRounding]::AwayFromZero)

            $controller = Get-ScsiController -VM $vm | where {$_.ExtensionData.busNumber -eq $diskControllerNumber}

            $diskControllerKey = $controller.ExtensionData.Key

            # Create Config Spec to add new VMDK & Enable Multi-Writer Flag

            $global:spec = New-Object VMware.Vim.VirtualMachineConfigSpec

            $spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[](1)

            $spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec

            $spec.deviceChange[0].operation = "add"

            $spec.deviceChange[0].device = New-Object VMware.Vim.VirtualDisk

            $spec.deviceChange[0].device.key = -1

            $spec.deviceChange[0].device.ControllerKey = $diskControllerKey

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

            $spec.deviceChange[0].device.CapacityInKB = $diskSizeInKB

            $spec.DeviceChange[0].device.backing = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

            $spec.DeviceChange[0].device.backing.Datastore = $ds.ExtensionData.MoRef

            $spec.DeviceChange[0].device.backing.fileName = $DiskPathocr01

            $spec.DeviceChange[0].device.backing.diskMode = 'independent_persistent'

            $spec.DeviceChange[0].device.backing.eagerlyScrub = $True

            $spec.extraConfig = New-Object VMware.Vim.OptionValue[](1)

            $spec.extraConfig[0] = New-Object VMware.Vim.OptionValue

            $spec.extraConfig[0].key = "scsi" + $diskControllerNumber + ":" + $diskUnitNumber + ".sharing"

            $spec.extraConfig[0].value = "multi-writer"

            $vm.ExtensionData.ReconfigVM($spec)

        }

    }

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

It was not only the Datastore property, but also the UnitNumber for the disk that was missing.

And your calculation for the controller's BusNumber was incorrect (I see you now hard-coded that).


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

Reply
0 Kudos
AntoP
Contributor
Contributor
Jump to solution

Yes I did, I tried to approach it by trying to determine busnumber, but the ctrl need to be ctrl1 and ctrl2, ctrl0 is reserverd for OS, so after trying and failing I decided to hardcode it, since I need it standardized across all the builds. But I see your point and I really appreciate your help, thanks!. what still puzzles me is the fact that none of the newly created disks (13) in each node got 'multi-writer', that still a TODO for me Smiley Happy

Thanks!

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Have you check my Re: Multiwriter Disk answer?

That one works.


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

Reply
0 Kudos
AntoP
Contributor
Contributor
Jump to solution

that one works, thanks!

function createocr01 {

    Function New-SCSICtrl {

        Param (

            [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True)]

            $vm

        )

        Process {

            $global:VMSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

            $VMSpec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[](2)

            $VMSpec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec

            $VMSpec.deviceChange[0].operation = "add"

            $VMSpec.deviceChange[0].device = New-Object VMware.Vim.ParaVirtualSCSIController

            $VMspec.deviceChange[0].device.busnumber = 1

            $VMspec.deviceChange[0].device.deviceInfo = New-Object VMware.Vim.Description

            $VMspec.deviceChange[0].device.deviceInfo.summary = ''

            $VMspec.deviceChange[0].device.deviceInfo.label = 'New SCSI controller'

            $VMspec.deviceChange[0].device.sharedBus = 'Physical'

            $VMspec.deviceChange[0].device.key = -1

            $VMSpec.deviceChange[1] = New-Object VMware.Vim.VirtualDeviceConfigSpec

            $VMSpec.deviceChange[1].operation = "add"

            $VMSpec.deviceChange[1].device = New-Object VMware.Vim.ParaVirtualSCSIController

            $VMspec.deviceChange[1].device.busnumber = 2

            $VMspec.deviceChange[1].device.deviceInfo = New-Object VMware.Vim.Description

            $VMspec.deviceChange[1].device.deviceInfo.summary = ''

            $VMspec.deviceChange[1].device.deviceInfo.label = 'New SCSI controller'

            $VMspec.deviceChange[1].device.sharedBus = 'Physical'

            $VMspec.deviceChange[1].device.key = -2

            $vm.ExtensionData.ReconfigVM($VMSpec)    

        }

    }

    

    Function add-dsk-node1 {

        Param (

            [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True)]

            $vm

        )

        Process {

            $ds = Get-Datastore -Name $storeocr01

            [int]$diskSizeGB = 10

            [int]$diskControllerNumber = 1

            [int]$diskUnitNumber = 0

            $vmName = Get-VM $node1 | select Name

            $node = Get-View -ViewType VirtualMachine -Property Name, Config.Hardware.Device -Filter @{"Name" = $vmName.Name}

            [int64]$diskSizeInKB = (($diskSizeGB * 1024 * 1024 * 1024) / 1KB)

            [int64]$diskSizeInKB = [Math]::Round($diskSizeInKB, 4, [MidPointRounding]::AwayFromZero)

            $controller = Get-ScsiController -VM $vm | where {$_.ExtensionData.busNumber -eq $diskControllerNumber}

            $diskControllerKey = $controller.ExtensionData.Key

            # Create Config Spec to add new VMDK & Enable Multi-Writer Flag

            $global:spec = New-Object VMware.Vim.VirtualMachineConfigSpec

            $spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[](1)

            $spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec

            $spec.deviceChange[0].operation = "add"

            $spec.DeviceChange[0].FileOperation = "create"

            $spec.deviceChange[0].device = New-Object VMware.Vim.VirtualDisk

            $spec.deviceChange[0].device.key = -1

            $spec.deviceChange[0].device.ControllerKey = $diskControllerKey

            $spec.deviceChange[0].device.CapacityInKB = $diskSizeInKB

            $spec.DeviceChange[0].Device.UnitNumber = $diskUnitNumber

            $spec.DeviceChange[0].device.backing = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

            $spec.DeviceChange[0].device.backing.Datastore = $ds.ExtensionData.MoRef

            $spec.DeviceChange[0].device.backing.fileName = $DiskPathocr01

            $spec.DeviceChange[0].device.backing.diskMode = 'independent_persistent'

            $spec.deviceChange[0].device.backing.thinProvisioned = $false

            $spec.deviceChange[0].device.backing.split = $false

            $spec.deviceChange[0].device.backing.writeThrough = $false

            $spec.deviceChange[0].device.backing.eagerlyScrub = $true

            $spec.deviceChange[0].device.backing.sharing = [VMware.Vim.VirtualDiskSharing]::sharingMultiWriter

            $vm.ExtensionData.ReconfigVM($spec)

        }

    }

    

    Function add-dsk-node2 {

        Param (

            [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True)]

            $vm

        )

        Process {

            $DiskPathocr01 = "[knx_vmax3_001] Prod-Shared/ProdOcr1.vmdk"

$storeocr01 = "knx_vmax3_001"

            $ds = Get-Datastore -Name $storeocr01

            [int]$diskSizeGB = 10

            [int]$diskControllerNumber = 1

            [int]$diskUnitNumber = 0

            $vmName = Get-VM $node2 | select Name

            $node = Get-View -ViewType VirtualMachine -Property Name, Config.Hardware.Device -Filter @{"Name" = $vmName.Name}

            [int64]$diskSizeInKB = (($diskSizeGB * 1024 * 1024 * 1024) / 1KB)

            [int64]$diskSizeInKB = [Math]::Round($diskSizeInKB, 4, [MidPointRounding]::AwayFromZero)

            $controller = Get-ScsiController -VM $vm | where {$_.ExtensionData.busNumber -eq $diskControllerNumber}

            $diskControllerKey = $controller.ExtensionData.Key

            # Create Config Spec to add new VMDK & Enable Multi-Writer Flag

            $global:spec = New-Object VMware.Vim.VirtualMachineConfigSpec

            $spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[](1)

            $spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec

            $spec.deviceChange[0].operation = "add"

            $spec.deviceChange[0].device = New-Object VMware.Vim.VirtualDisk

            $spec.deviceChange[0].device.key = -1

            $spec.deviceChange[0].device.ControllerKey = $diskControllerKey

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

            $spec.deviceChange[0].device.CapacityInKB = $diskSizeInKB

            $spec.DeviceChange[0].device.backing = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

            $spec.DeviceChange[0].device.backing.Datastore = $ds.ExtensionData.MoRef

            $spec.DeviceChange[0].device.backing.fileName = $DiskPathocr01

            $spec.DeviceChange[0].device.backing.diskMode = 'independent_persistent'

            $spec.DeviceChange[0].device.backing.eagerlyScrub = $True

            $spec.deviceChange[0].device.backing.sharing = [VMware.Vim.VirtualDiskSharing]::sharingMultiWriter

            $vm.ExtensionData.ReconfigVM($spec)

        }

    }

    $node1 | New-SCSICtrl

    $node2 | New-SCSICtrl

    #Get-VM $node1, $node2 | Get-ScsiController

    $node1 | add-dsk-node1

    $node2 | add-dsk-node2

}

Thanks all for the help!

Reply
0 Kudos