PowerCLI

 View Only
Expand all | Collapse all

need to check multiwriter is enabled in VM

LucD

LucDMar 27, 2015 04:37 PMBest Answer

Vel_VMware

Vel_VMwareJun 28, 2017 01:15 PM

  • 1.  need to check multiwriter is enabled in VM

    Posted Mar 27, 2015 03:35 PM

    Hi All,

       Thanks in Advance.

       For creating build verification documents, I need to check if the particular VM is enabled with multi writer disk's or not .Any help much appreciated.

    I need a report some thing like the following.

       

    Header 1Header 2Header 3Header 2
    Capacity GBStorageFormatFilenameMulti-writer
    40 GBEagerZeroedThick[LUN-1]vmtest.vmdkno
    60 GBEagerZeroedThick[LUN-1]vmtest_1.vmdkyes


  • 2.  RE: need to check multiwriter is enabled in VM
    Best Answer

    Posted Mar 27, 2015 04:37 PM

    Try something like this

    Get-VM | Get-HardDisk | %{

        $ctrl = Get-ScsiController -HardDisk $_

        $_ | Select @{N='VM';E={$_.Parent.Name}},

            Name,

            StorageFormat,

            FileName,

            @{N='Multi-Writer';E={

               Get-AdvancedSetting -Entity $_.Parent -Name "scsi$($ctrl.ExtensionData.BusNumber):$($_.ExtensionData.UnitNumber).sharing" |

               Select -ExpandProperty Value

            }}

    }



  • 3.  RE: need to check multiwriter is enabled in VM

    Posted Jun 27, 2017 01:07 PM

    Hi,

    Excellent, thanks a lot.

    Can you please add two more information in that script Cluster and host please and can be export in .csv

    Thanks and Regards,



  • 4.  RE: need to check multiwriter is enabled in VM

    Posted Jun 27, 2017 01:17 PM

    Sure, try like this

    Get-VM | Get-HardDisk | %{

        $ctrl = Get-ScsiController -HardDisk $_

        $_ | Select @{N='VM';E={$_.Parent.Name}},

            @{N='VMHost';E={$_.Parent.VMHost.Name}},

            @{N='Cluster';E={Get-Cluster -VM $_.Parent | Select -ExpandProperty Name}},

            Name,

            StorageFormat,

            FileName,

            @{N='Multi-Writer';E={

               Get-AdvancedSetting -Entity $_.Parent -Name "scsi$($ctrl.ExtensionData.BusNumber):$($_.ExtensionData.UnitNumber).sharing" |

               Select -ExpandProperty Value

            }}

    }



  • 5.  RE: need to check multiwriter is enabled in VM

    Posted Jun 27, 2017 02:04 PM

    Hi,

    Superb, I tried to export it in .CSV by adding below command at the end, but no luck.

    "$ctrl | Export-CSV C:\MultiWriter.csv"



  • 6.  RE: need to check multiwriter is enabled in VM

    Posted Jun 27, 2017 04:22 PM

    The ForEach block doesn't place anything on the pipeline.

    One way of capturing and exporting the result is like this

    $report = Get-VM | Get-HardDisk | %{

        $ctrl = Get-ScsiController -HardDisk $_

        $_ | Select @{N='VM';E={$_.Parent.Name}},

            @{N='VMHost';E={$_.Parent.VMHost.Name}},

            @{N='Cluster';E={Get-Cluster -VM $_.Parent | Select -ExpandProperty Name}},

            Name,

            StorageFormat,

            FileName,

            @{N='Multi-Writer';E={

               Get-AdvancedSetting -Entity $_.Parent -Name "scsi$($ctrl.ExtensionData.BusNumber):$($_.ExtensionData.UnitNumber).sharing" |

               Select -ExpandProperty Value

            }}

    }

    $report | Export-Csv -Path C:\MultiWriter.csv -NoTypeInformation -UseCulture



  • 7.  RE: need to check multiwriter is enabled in VM

    Posted Jun 28, 2017 01:15 PM

    Hi,

    Thanks a looooot......It works great.



  • 8.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 08:17 AM

    Hi,

    I am getting empty in multiwriter column and no data, can you please it in the script.

    Thanks in advance.



  • 9.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 08:19 AM

    If there is multi-writer set, you will get an empty cell.

    Only when there is an entry will you see True or False in the column.



  • 10.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 08:27 AM

    I couldn't get you, you meant, If there is no multi-writer set, will get an empty cell...?

    Where I will get an entry True or False? In my case, I have number of multi writer enabled VM's but I got empty cells on those VM's also.

    Can you please clarify me..



  • 11.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 08:43 AM

    If multi-write is set for a vDisk on a VM, you should have an Advanced Setting on the VM that looks like scsix:y.sharing = “multi-writer”.

    The value on that key is what you should see in the column (it's not True or False, I was wrong).

    When you do a Get-AdvancedSetting for a VM with multi-write enabled, do you see such entries being returned?

    Get-AdvancedSetting -Entity (Get-VM MyVM) | where{$_.Name -match "^scsi.*sharing"}



  • 12.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 10:16 AM

    Yeah, its there in VMX config file. I have created that shared disk.



  • 13.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 10:18 AM

    Can you show me a sample entry?

    I would like to verify that the calculated property is querying for the correct key.



  • 14.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 10:28 AM

    Do I need to add this below line in the script.?

    Get-AdvancedSetting -Entity (Get-VM MyVM) | where{$_.Name -match "^scsi.*sharing"}



  • 15.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 10:33 AM

    No, just run that line by itself, and replace the MyVM by one of your VMnames (one where you know that multi-writer is defined).



  • 16.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 11:17 AM

    I am not getting any out after running that given single line script. Its just simply came out from run time after completion of script execution.



  • 17.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 11:30 AM

    Leave out the where-clause and see if you can find the multi-write entry in the output.



  • 18.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 01:51 PM

    Yeah, I could see scsi.x:x - multi-writer, I got the response blank in multi writer while running script.

    What should I get the out for this, True or False or blank in multiwriter column.



  • 19.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 04:25 PM

    Looks like the Advanced Settings doesn't list that value anymore, at least not in vSphere 6.5.

    Try this alternative method

    Get-VM | Get-HardDisk | %{

        $ctrl = Get-ScsiController -HardDisk $_

        $_ | Select @{N='VM';E={$_.Parent.Name}},

            Name,

            StorageFormat,

            FileName,

            @{N='Multi-Writer';E={$_.ExtensionData.Backing.Sharing}}

    }



  • 20.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 06:36 PM

    I had this problem a while ago. We were able to check 'multi-writer' flag from 'Advanced Setting', when the VMs were on ESXi 5.5. After an upgrade to 6.0, the multi-writer values disappeared from Advanced Setting and the only way we could check is by opening the vmx file of the VM.

    I did try $_.ExtensionData.Backing.Sharing but it is showing empty, but the VM does have multi-writer enabled on the vmx.



  • 21.  RE: need to check multiwriter is enabled in VM

    Posted Jun 29, 2017 06:57 PM

    In 6.5 the Backing property seems to work.

    So it looks like in 6 one needs to check the VMX (I'll verify that in any case)



  • 22.  RE: need to check multiwriter is enabled in VM

    Posted Jun 30, 2017 07:12 AM

    On 6 the Backing seems to provide the multi-writer state as well.

    Only until 5.5 do you need to access the VMX (through the Get-AdvancedSettings cmdlet).

    The following script test the version, and retrieves the setting accordingly

    Get-VM | Get-HardDisk | %{

        $ctrl = Get-ScsiController -HardDisk $_

        $_ | Select @{N='VM';E={$_.Parent.Name}},

            Name,

            StorageFormat,

            FileName,

            @{N='Multi-Writer';E={

                if($_.Parent.VMHost.ApiVersion -le "5.5"){

                    $ctrl = Get-ScsiController -HardDisk $_

                    Get-AdvancedSetting -Entity $_.Parent -Name "scsi$($ctrl.ExtensionData.BusNumber):$($_.ExtensionData.UnitNumber).sharing" |

                    Select -ExpandProperty Value

                }

                else{

                    $_.ExtensionData.Backing.Sharing

                }

           }}

    }



  • 23.  RE: need to check multiwriter is enabled in VM

    Posted Jul 03, 2017 03:34 PM

    Excellent, thanks a lot for your effort, its working as I expected.



  • 24.  RE: need to check multiwriter is enabled in VM

    Posted Nov 29, 2019 10:35 AM

    Hi LuCD,

    Hope you are doing good.

    After long break coming back to same thread. You have provided me the script to get "Multiwriter" has been enabled for VM's. Thats works great too.

    I just want to have the same kind of script to get same "Multiwriter" has been enabled for specific list of VM's. Which means I would be having the list of VM's in .csv format and providing this an input and it has to get whether those VM's are enabled with "Multiwriter" or not.

    Can you please help me on this..

    Thanks in advance



  • 25.  RE: need to check multiwriter is enabled in VM

    Posted Nov 29, 2019 11:35 AM

    Sure, but I suggest you open a new thread for that.
    That makes it easier for others to find it.