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 1 | Header 2 | Header 3 | Header 2 |
---|---|---|---|
Capacity GB | StorageFormat | Filename | Multi-writer |
40 GB | EagerZeroedThick | [LUN-1]vmtest.vmdk | no |
60 GB | EagerZeroedThick | [LUN-1]vmtest_1.vmdk | yes |
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
}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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,
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
}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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"
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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
Thanks a looooot......It works great.
Hi,
I am getting empty in multiwriter column and no data, can you please it in the script.
Thanks in advance.
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.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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..
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"}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yeah, its there in VMX config file. I have created that shared disk.
Can you show me a sample entry?
I would like to verify that the calculated property is querying for the correct key.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Do I need to add this below line in the script.?
Get-AdvancedSetting -Entity (Get-VM MyVM) | where{$_.Name -match "^scsi.*sharing"}
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).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
Leave out the where-clause and see if you can find the multi-write entry in the output.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
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}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.